diff --git a/fnl/init.fnl b/fnl/init.fnl new file mode 100644 index 0000000..4b90e51 --- /dev/null +++ b/fnl/init.fnl @@ -0,0 +1,83 @@ + +(module init + {require {a aniseed.core + nvim aniseed.nvim} + require-macros [macros] + include {keybinds keybinds}}) + +(set nvim.g.conjure#client#fennel#aniseed#aniseed_module_prefix "aniseed.") + + +(local lsp (require "lspconfig")) +(local util lsp.util) +(local saga (require "lspsaga")) +(local compe (require "compe")) + + +(fn on_attach [client bufnr] + (if client.resolved_capabilities.document_highlight + (nvim.api.nvim_exec + "hi LspReferenceRead cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828' + hi LspReferenceText cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828' + hi LspReferenceWrite cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828' + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + " + false))) + + + +(lsp.rust_analyzer.setup { :on_attach on_attach}) +(lsp.jsonls.setup { :on_attach on_attach}) +(lsp.vimls.setup { :on_attach on_attach}) +(lsp.tsserver.setup { :on_attach on_attach}) +(lsp.bashls.setup { :on_attach on_attach}) +(lsp.html.setup { :on_attach on_attach}) + +(lsp.denols.setup + { :on_attach on_attach + :root_dir (lsp.util.root_pattern ".git")}) +(lsp.hls.setup + { :on_attach on_attach + :settings { :languageServerHaskell { :formattingProvider "stylish-haskell"}}}) + + +(compe.setup + { :enabled true + :autocomplete true + :debug false + :min_length 1 + :preselect "enable" + :throttle_time 80 + :source_timeout 200 + :incomplete_delay 400 + :max_abbr_width 100 + :max_kind_width 100 + :max_menu_width 100 + :documentation true + :source { :path true + :buffer true + :calc true + :nvim_lsp true + :nvim_lua true + :vsnip false}}) + + +(saga.init_lsp_saga + { :border_style 1 + :code_action_keys { :quit "" :exec ""} + :rename_action_keys { :quit "" :exec ""} + :finder_action_keys + { :quit "" + :open "" + :vsplit "v" + :split "b" + :scroll_up "" + :scroll_down ""}}) + + + + diff --git a/fnl/keybinds.fnl b/fnl/keybinds.fnl new file mode 100644 index 0000000..763f688 --- /dev/null +++ b/fnl/keybinds.fnl @@ -0,0 +1,78 @@ +(module keybinds + {require {a aniseed.core + nvim aniseed.nvim + util util} + require-macros [macros]}) + + +(util.noremap :n : ":WhichKey ''") +(util.noremap :v : ":WhichKeyVisual ''") + + +(util.mapexpr :i : "compe#complete()") +(util.mapexpr :i : "compe#confirm('')") +(util.mapexpr :i : "compe#complete('')") + + + +(fn le [s] (.. ":call luaeval \"" s "\")")) + +(set nvim.g.which_key_map {}) +(nvim.command "call which_key#register('', \"g:which_key_map\")") + +(set nvim.g.which_key_map + { "h" [ ":bprevious" "previous buffer"] + "l" [ ":bnext" "next buffer"] + "f" "which_key_ignore" + "s" "which_key_ignore" + "[" ["(YoinkPostPasteSwapBack)" "Swap last paste backwards"] + "]" ["(YoinkPostPasteSwapForward)" "Swap last paste backwards"] + ":" [":Commands" "Search command with fzf"] + "c" { :name "+comment_out"} + "e" { :name "+emmet"} + + "z" { :name "+folds" + "c" ["foldclose" "close fold"] + "o" ["foldopen" "open fold"]} + + "m" { :name "+Code-actions" + "d" [ ":Lspsaga hover_doc" "show documentation"] + "b" [ ":Lspsaga lsp_finder" "find stuff"] + "x" [ ":Lspsaga preview_definition" "Preview definition"] + "o" [ ":Telescope lsp_document_symbols" "symbols in document"] + "s" [ ":Telescope lsp_workspace_symbols" "symbols in workspace"] + "t" [ ":Lspsaga signature_help" "Show signature help"] + "n" [ ":Lspsaga rename" "rename"] + "v" [ ":Lspsaga code_action" "apply codeaction"] + "a" [ ":Lspsaga show_cursor_diagnostics" "Cursor diagnostics"] + "A" [ ":Lspsaga show_line_diagnostics" "Line diagnostics"] + "E" [ ":Telescope lsp_workspace_diagnostics" "List diagnostics"] + "e" [ (le "vim.lsp.diagnostic.goto_next()") "Jump to the next error"] + "g" [ (le "vim.lsp.buf.definition()") "go to definition"] + "i" [ (le "vim.lsp.buf.implementation()") "show implementation"] + "r" [ (le "vim.lsp.buf.references()") "show references"] + "f" [ (le "vim.lsp.buf.formatting()") "format file"]} + + + "f" { :name "+folds" + "o" [ ":foldopen" "open fold"] + "n" [ ":foldclose" "close fold"] + "j" [ "zj" "jump to next fold"] + "k" [ "zk" "jump to previous fold"]} + + "v" { :name "+view-and-layout" + "n" [":set relativenumber!" "toggle relative numbers"] + "m" [":set nonumber! norelativenumber" "toggle numbers"] + "g" [":Goyo | set linebreak" "toggle focus mode"] + "i" [":IndentGuidesToggle" "toggle indent guides"]}}) + +(set nvim.o.timeoutlen 200) + +; TODO +; autocmd! VimEnter * :unmap ig +; autocmd! FileType which_key) + + + + + diff --git a/fnl/macros.fnl b/fnl/macros.fnl new file mode 100644 index 0000000..2d6d553 --- /dev/null +++ b/fnl/macros.fnl @@ -0,0 +1,19 @@ +{:augroup + (fn [name ...] + `(do + (nvim.ex.augroup ,(tostring name)) + (nvim.ex.autocmd_) + ,... + (nvim.ex.augroup :END))) + + :autocmd + (fn [...] + `(nvim.ex.autocmd ,...)) + + :_: + (fn [name ...] + `((. nvim.ex ,(tostring name)) ,...)) + + :viml->fn + (fn [name] + `(.. "lua require('" *module-name* "')['" ,(tostring name) "']()"))} diff --git a/fnl/util.fnl b/fnl/util.fnl new file mode 100644 index 0000000..4902e0b --- /dev/null +++ b/fnl/util.fnl @@ -0,0 +1,13 @@ +(module util + {require {a aniseed.core + nvim aniseed.nvim} + require-macros [macros]}) + +(defn noremap [mode from to] + "Sets a mapping with {:noremap true :silent true}." + (nvim.set_keymap mode from to {:noremap true :silent true})) + +(defn mapexpr [mode from to] + "Sets a mapping with {:noremap true :silent true :expr true}." + (nvim.set_keymap mode from to {:noremap true :silent true :expr true})) + diff --git a/init.vim b/init.vim index 31a3325..e9db202 100644 --- a/init.vim +++ b/init.vim @@ -54,7 +54,7 @@ set autoindent smartindent noet expandtab set nowrap set noshowmode " hide the mode as shown by vim, because the status line does it better! -set completeopt=longest,menuone " Enable autocompletion +set completeopt=longest,menuone,noselect " Enable autocompletion set laststatus=2 set noshowmode @@ -353,14 +353,13 @@ source $VIM_ROOT/whichkeyConfig.vim luafile $VIM_ROOT/lsp.lua "source $VIM_ROOT/lsp.vim - -" this is apparently necessary for nvim-lsp stuff -set completeopt=menuone,noselect +let g:aniseed#env = v:true -inoremap compe#complete() -inoremap compe#confirm('') -inoremap compe#close('') + +"inoremap compe#complete() +"inoremap compe#confirm('') +"inoremap compe#close('') "nnoremap lua require('lspsaga.action').smart_scroll_with_saga(1) diff --git a/plugins.vim b/plugins.vim index 55a0280..e43797e 100644 --- a/plugins.vim +++ b/plugins.vim @@ -10,6 +10,9 @@ call plug#begin('~/.vim/plugged') Plug 'Olical/aniseed', { 'tag': 'v3.16.0' } Plug 'bakpakin/fennel.vim' + " general purpose lua wrappers for nvim stuff + Plug 'norcalli/nvim.lua' + Plug 'tweekmonster/startuptime.vim' Plug 'tpope/vim-repeat' @@ -128,11 +131,14 @@ call plug#begin('~/.vim/plugged') "Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'thyrgle/vim-dyon' + Plug 'bakpakin/fennel.vim' + Plug 'tjdevries/nlua.nvim' Plug 'nvim-lua/completion-nvim' "Plug 'mxw/vim-prolog' + Plug 'neovim/nvim-lspconfig' Plug 'hrsh7th/nvim-compe' Plug 'glepnir/lspsaga.nvim' diff --git a/whichkeyConfig.vim b/whichkeyConfig.vim index b02246d..b49ea57 100644 --- a/whichkeyConfig.vim +++ b/whichkeyConfig.vim @@ -1,7 +1,7 @@ -nnoremap :WhichKey '' -vnoremap :'WhichKeyVisual '' -let g:which_key_map = {} -call which_key#register('', "g:which_key_map") +"nnoremap :WhichKey '' +"vnoremap :'WhichKeyVisual '' +"let g:which_key_map = {} +"call which_key#register('', "g:which_key_map") @@ -10,18 +10,18 @@ call which_key#register('', "g:which_key_map") "\ 'h' : 'which_key_ignore', 'l' : 'which_key_ignore' , "\ 'h' : ':bprevious', 'l' : ':bnext' , "\ 'h' : [':BufferPrevious', 'prev buffer'], 'l' : [':BufferNext', 'next buffer'] , -let g:which_key_map = { - \ 'h' : [':bprevious', 'prev buffer'], 'l' : [':bnext', 'next buffer'], - \ 'f' : 'which_key_ignore', 's': 'which_key_ignore' , - \ 'c' : { 'name': '+comment_out' }, - \ 'e' : { 'name': '+emmet' }, - \ '[' : ['(YoinkPostPasteSwapBack)', 'Swap last paste backwards' ], - \ ']' : ['(YoinkPostPasteSwapForward)', 'Swap last paste backwards' ], - \ ':' : [':Commands' , 'Search command with fzf' ], - \ 'z' : { 'name': '+folds', 'c': ['foldclose', 'close fold'], - \ 'o': ['foldopen', 'open fold'] , - \ } - \ } +"let g:which_key_map = { + "\ 'h' : [':bprevious', 'prev buffer'], 'l' : [':bnext', 'next buffer'], + "\ 'f' : 'which_key_ignore', 's': 'which_key_ignore' , + "\ 'c' : { 'name': '+comment_out' }, + "\ 'e' : { 'name': '+emmet' }, + "\ '[' : ['(YoinkPostPasteSwapBack)', 'Swap last paste backwards' ], + "\ ']' : ['(YoinkPostPasteSwapForward)', 'Swap last paste backwards' ], + "\ ':' : [':Commands' , 'Search command with fzf' ], + "\ 'z' : { 'name': '+folds', 'c': ['foldclose', 'close fold'], + "\ 'o': ['foldopen', 'open fold'] , + "\ } + "\ } "\ 's' : [ ':CocFzfList symbols' , 'list symbols' ] , @@ -45,25 +45,26 @@ let g:which_key_map = { "\ 'a' : [ ':call luaeval("vim.lsp.diagnostic.show_line_diagnostics()")' , 'diagnostics info' ] , "\ } -let g:which_key_map['m'] = { - \ 'name' : '+Code-actions' , - \ 'd' : [ ':Lspsaga hover_doc' , 'show documentation' ] , - \ 'b' : [ ':Lspsaga lsp_finder' , 'find stuff' ] , - \ 'x' : [ ':Lspsaga preview_definition' , 'Preview definition' ] , - \ 'o' : [ ':Telescope lsp_document_symbols' , 'symbols in document' ] , - \ 's' : [ ':Telescope lsp_workspace_symbols' , 'symbols in workspace' ] , - \ 'g' : [ ':call luaeval("vim.lsp.buf.definition()")' , 'go to definition' ] , - \ 't' : [ ':Lspsaga signature_help' , 'Show signature help' ] , - \ 'i' : [ ':call luaeval("vim.lsp.buf.implementation()")' , 'show implementation' ] , - \ 'r' : [ ':call luaeval("vim.lsp.buf.references()")' , 'show references' ] , - \ 'n' : [ ':Lspsaga rename' , 'rename' ] , - \ 'f' : [ ':call luaeval("vim.lsp.buf.formatting()")' , 'format file' ] , - \ 'v' : [ ':Lspsaga code_action' , 'apply codeaction' ] , - \ 'e' : [ ':call luaeval("vim.lsp.diagnostic.goto_next()")' , 'Jump to the next error' ] , - \ 'E' : [ ':Telescope lsp_workspace_diagnostics' , 'List diagnostics' ] , - \ 'a' : [ ':Lspsaga show_cursor_diagnostics' , 'Cursor diagnostics' ] , - \ 'A' : [ ':Lspsaga show_line_diagnostics' , 'Line diagnostics' ] , - \ } +" this is the one! +"let g:which_key_map['m'] = { + "\ 'name' : '+Code-actions' , + "\ 'd' : [ ':Lspsaga hover_doc' , 'show documentation' ] , + "\ 'b' : [ ':Lspsaga lsp_finder' , 'find stuff' ] , + "\ 'x' : [ ':Lspsaga preview_definition' , 'Preview definition' ] , + "\ 'o' : [ ':Telescope lsp_document_symbols' , 'symbols in document' ] , + "\ 's' : [ ':Telescope lsp_workspace_symbols' , 'symbols in workspace' ] , + "\ 'g' : [ ':call luaeval("vim.lsp.buf.definition()")' , 'go to definition' ] , + "\ 't' : [ ':Lspsaga signature_help' , 'Show signature help' ] , + "\ 'i' : [ ':call luaeval("vim.lsp.buf.implementation()")' , 'show implementation' ] , + "\ 'r' : [ ':call luaeval("vim.lsp.buf.references()")' , 'show references' ] , + "\ 'n' : [ ':Lspsaga rename' , 'rename' ] , + "\ 'f' : [ ':call luaeval("vim.lsp.buf.formatting()")' , 'format file' ] , + "\ 'v' : [ ':Lspsaga code_action' , 'apply codeaction' ] , + "\ 'e' : [ ':call luaeval("vim.lsp.diagnostic.goto_next()")' , 'Jump to the next error' ] , + "\ 'E' : [ ':Telescope lsp_workspace_diagnostics' , 'List diagnostics' ] , + "\ 'a' : [ ':Lspsaga show_cursor_diagnostics' , 'Cursor diagnostics' ] , + "\ 'A' : [ ':Lspsaga show_line_diagnostics' , 'Line diagnostics' ] , + "\ } "let g:which_key_map['m'] = { "\ 'name' : '+Code-actions' , @@ -89,54 +90,44 @@ let g:which_key_map['m'] = { "\ 'O' : [ '(coc-openlink)' , 'open link under cursor' ] , "\} -let g:which_key_map['f'] = { - \ 'name': '+folds', - \ 'o': [ ':foldopen' , 'open fold' ] , - \ 'n': [ ':foldclose' , 'close fold' ] , - \ 'j': [ 'zj' , 'jump to next fold' ] , - \ 'k': [ 'zk' , 'jump to previous fold' ] , - \ } +"let g:which_key_map['f'] = { + "\ 'name': '+folds', + "\ 'o': [ ':foldopen' , 'open fold' ] , + "\ 'n': [ ':foldclose' , 'close fold' ] , + "\ 'j': [ 'zj' , 'jump to next fold' ] , + "\ 'k': [ 'zk' , 'jump to previous fold' ] , + "\ } -let g:which_key_map['a'] = { - \ 'name': '+Bookmarks', - \ ' ' : ['(coc-bookmark-toggle)' , 'toggle bookmark' ] , - \ 'a' : ['(coc-bookmark-annotate)' , 'annotate bookmark' ] , - \ 'j' : ['(coc-bookmark-next)' , 'next bookmark' ] , - \ 'k' : ['(coc-bookmark-prev)' , 'prev bookmark' ] , - \ 'l' : [':CocList bookmark' , 'list bookmarks' ] , - \ 'c' : [':CocCommand bookmark.clearForCurrentFile' , 'clear for current file' ] , - \ 'C' : [':CocCommand bookmark.clearForAllFiles' , 'clear for all files' ] - \} -" mappings for view and layout -let g:which_key_map['v'] = { - \ 'name' : '+view-and-layout', - \ 'n' : [':set relativenumber!' , 'toggle relative numbers' ] , - \ 'm' : [':set nonumber! norelativenumber' , 'toggle numbers'] , - \ 'g' : [':Goyo | set linebreak' , 'toggle focus mode' ] , - \ 'i' : [':IndentGuidesToggle' , 'toggle indent guides' ] , - \ } +"" mappings for view and layout +"let g:which_key_map['v'] = { + "\ 'name' : '+view-and-layout', + "\ 'n' : [':set relativenumber!' , 'toggle relative numbers' ] , + "\ 'm' : [':set nonumber! norelativenumber' , 'toggle numbers'] , + "\ 'g' : [':Goyo | set linebreak' , 'toggle focus mode' ] , + "\ 'i' : [':IndentGuidesToggle' , 'toggle indent guides' ] , + "\ } - " :bwipeout! bdelete! - "\ 'b' : ['BufferPick' , 'select open buffer' ] , - "\ 'c' : ['BufferClose', 'close open buffer' ] , - "\ 'w' : ['BufferWipeout', 'wipeout open buffer' ] , -let g:which_key_map['b'] = { - \ 'name': '+buffers', - \ 'b' : [':Buffers' , 'select open buffer' ] , - \ 'c' : [':bdelete!', 'close open buffer' ] , - \ 'w' : [':bwipeout!', 'wipeout open buffer' ] , - \ } + "" :bwipeout! bdelete! + ""\ 'b' : ['BufferPick' , 'select open buffer' ] , + ""\ 'c' : ['BufferClose', 'close open buffer' ] , + ""\ 'w' : ['BufferWipeout', 'wipeout open buffer' ] , +"let g:which_key_map['b'] = { + "\ 'name': '+buffers', + "\ 'b' : [':Buffers' , 'select open buffer' ] , + "\ 'c' : [':bdelete!', 'close open buffer' ] , + "\ 'w' : [':bwipeout!', 'wipeout open buffer' ] , + "\ } -let g:which_key_map['x'] = { - \ 'name' : '+other', - \ 'f' : ['NERDTreeToggle' , ' show file tree'], - \ 'p' : ['FZF' , ' search file (c-v/c-x to open in split)' ] , - \ 'h' : [':History:' , 'search command history'], - \ 'c' : [':Commands' , 'search through commands'], - \ 's' : ['OverCommandLine', 'Substitute with preview'], - \ 'y' : [':CocFzfList yank', 'Show yank history'] - \ } +"let g:which_key_map['x'] = { + "\ 'name' : '+other', + "\ 'f' : ['NERDTreeToggle' , ' show file tree'], + "\ 'p' : ['FZF' , ' search file (c-v/c-x to open in split)' ] , + "\ 'h' : [':History:' , 'search command history'], + "\ 'c' : [':Commands' , 'search through commands'], + "\ 's' : ['OverCommandLine', 'Substitute with preview'], + "\ 'y' : [':CocFzfList yank', 'Show yank history'] + "\ } " CocList -A --normal yank needs :CocInstall coc-yank @@ -148,5 +139,5 @@ let g:which_key_map['x'] = { "autocmd! FileType which_key set laststatus=2 noshowmode noruler "\| autocmd! BufLeave set laststatus=2 showmode ruler -set timeoutlen=200 +"set timeoutlen=200