diff --git a/nvim/.config/nvim/fnl/help-thingy.fnl b/nvim/.config/nvim/fnl/help-thingy.fnl index 479578f..60469c4 100644 --- a/nvim/.config/nvim/fnl/help-thingy.fnl +++ b/nvim/.config/nvim/fnl/help-thingy.fnl @@ -6,6 +6,25 @@ ts nvim-treesitter} require-macros [macros]}) +(defn pop [text ft] + "Open a popup with the given text and filetype" + (var width 20) + (each [_ line (ipairs text)] + (set width (math.max width (length line)))) + (let [bufnr (vim.api.nvim_create_buf false true)] + (vim.api.nvim_buf_set_option bufnr :bufhidden "wipe") + (vim.api.nvim_buf_set_option bufnr :filetype ft) + (vim.api.nvim_buf_set_lines bufnr 0 -1 true text) + (popup.create bufnr {:padding [1 1 1 1] :width width}))) + + +(defn get-current-word [] + "Return the word the cursor is currently hovering over" + (let [col (. (vim.api.nvim_win_get_cursor 0) 2) + line (vim.api.nvim_get_current_line)] + (.. (vim.fn.matchstr (line:sub 1 (+ col 1)) "\\k*$") + (string.sub (vim.fn.matchstr (line:sub (+ col 1)) "^\\k*") + 2)))) (def helpfiles-path (str.join "/" (a.butlast (str.split vim.o.helpfile "/")))) (def tags diff --git a/nvim/.config/nvim/fnl/init.fnl b/nvim/.config/nvim/fnl/init.fnl index 289e1c8..d592f10 100644 --- a/nvim/.config/nvim/fnl/init.fnl +++ b/nvim/.config/nvim/fnl/init.fnl @@ -11,8 +11,6 @@ (macro make-errors-epic [f] `(xpcall #,f #(a.println (fennel.traceback $1)))) - - (when (vim.fn.has "termguicolors") (se termguicolors true)) @@ -79,6 +77,9 @@ (vim.cmd "autocmd! TextYankPost * silent! lua vim.highlight.on_yank {higroup=\"IncSearch\", timeout=300}") + + + ; foldend ; Colors ------------------------------------------------------- foldstart diff --git a/nvim/.config/nvim/fnl/keybinds.fnl b/nvim/.config/nvim/fnl/keybinds.fnl index 024f55b..7919ed4 100644 --- a/nvim/.config/nvim/fnl/keybinds.fnl +++ b/nvim/.config/nvim/fnl/keybinds.fnl @@ -9,7 +9,8 @@ (utils.keymap :i : "compe#complete()" {:expr true}) -(utils.keymap :i : "compe#close('')" {:expr true}) +;(utils.keymap :i : "compe#close('')" {:expr true}) +(utils.keymap :i :kj "compe#close('')" {:expr true}) (utils.keymap [:n] : "Telescope find_files") diff --git a/nvim/.config/nvim/fnl/plugins.fnl b/nvim/.config/nvim/fnl/plugins.fnl index dbadf6d..6a87581 100644 --- a/nvim/.config/nvim/fnl/plugins.fnl +++ b/nvim/.config/nvim/fnl/plugins.fnl @@ -75,7 +75,11 @@ :folke/lsp-trouble.nvim {:mod "plugins.trouble"} :simrat39/symbols-outline.nvim {:mod "plugins.symbols-outline"} :neovim/nvim-lspconfig {} - :hrsh7th/nvim-compe {:mod "plugins.compe"} + + ;:hrsh7th/nvim-compe {:mod "plugins.compe"} + :/home/leon/coding/prs/nvim-compe {:mod "plugins.compe"} + + :glepnir/lspsaga.nvim {:mod "plugins.lspsaga"} diff --git a/nvim/.config/nvim/fnl/plugins/compe.fnl b/nvim/.config/nvim/fnl/plugins/compe.fnl index fe647dc..36a6728 100644 --- a/nvim/.config/nvim/fnl/plugins/compe.fnl +++ b/nvim/.config/nvim/fnl/plugins/compe.fnl @@ -1,5 +1,20 @@ (module plugins.compe - {autoload {compe compe}}) + {require {compe compe}}) + + +(defn result-formatter [items] + (var max-width 0) + (each [_ item (ipairs items)] + (set item.abbr (-> item.abbr + (string.gsub "~$" "") + (string.gsub " %(.*%)$" ""))) + (set max-width (math.max max-width (vim.fn.strwidth item.abbr)))) + (each [_ item (ipairs items)] + (let [padding (string.rep " " (- max-width (vim.fn.strwidth item.abbr))) + details (?. item :user_data :compe :completion_item :detail)] + (when details + (set item.abbr (.. item.abbr padding " " details))))) + items) (compe.setup {:enabled true @@ -14,6 +29,7 @@ :max_kind_width 100 :max_menu_width 100 :documentation true + :formatting_functions {:nvim_lsp {:results result-formatter}} :source {:path true :buffer true :calc true diff --git a/nvim/.config/nvim/fnl/plugins/feline.fnl b/nvim/.config/nvim/fnl/plugins/feline.fnl index 9a03411..9c82843 100644 --- a/nvim/.config/nvim/fnl/plugins/feline.fnl +++ b/nvim/.config/nvim/fnl/plugins/feline.fnl @@ -11,8 +11,6 @@ require-macros [macros]}) - - (local modes {:n {:text "NORMAL" :color colors.neutral_aqua} :i {:text "INSERT" :color colors.neutral_yellow} @@ -65,8 +63,8 @@ (defn lsp-progress-provider [] (let [msgs (vim.lsp.util.get_progress_messages) s (icollect [_ msg (ipairs msgs)] - (when msg.message - (.. msg.title " " msg.message)))] + (when msg.message + (.. msg.title " " msg.message)))] (or-empty (str.join " | " s)))) diff --git a/nvim/.config/nvim/fnl/plugins/lsp.fnl b/nvim/.config/nvim/fnl/plugins/lsp.fnl index 2fb9670..6344775 100644 --- a/nvim/.config/nvim/fnl/plugins/lsp.fnl +++ b/nvim/.config/nvim/fnl/plugins/lsp.fnl @@ -1,14 +1,14 @@ (module plugins.lsp - {require {a aniseed.core - lsp lspconfig - lsp-configs lspconfig.configs - utils utils} + {require {a aniseed.core + lsp lspconfig + lsp-configs lspconfig.configs + utils utils} - require-macros [macros]}) + require-macros [macros]}) (fn on_attach [client bufnr] (pkg lsp_signature.nvim [lsp_signature (require "lsp_signature")] - (lsp_signature.on_attach)) + (lsp_signature.on_attach)) (if client.resolved_capabilities.document_highlight (do @@ -16,11 +16,11 @@ (utils.highlight "LspReferenceText" {:gui "underline"}) (utils.highlight "LspReferenceWrite" {:gui "underline"}) (vim.api.nvim_exec - "augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END" + "augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END" false)))) @@ -36,18 +36,18 @@ "initialize a language server with defaults" (let [merged-opts (a.merge {:on_attach on_attach} (or ?opts {}))] ((. lsp lsp-name :setup) merged-opts))) - +; Added capabilities for rust-analyzer with nvim-compe (let [capabilities (vim.lsp.protocol.make_client_capabilities)] (set capabilities.textDocument.completion.completionItem.snippetSupport true) (set capabilities.textDocument.completion.completionItem.resolveSupport - {:properties ["documentation" "detail" "additionalTextEdits"]}) + {:properties ["documentation" "detail" "additionalTextEdits"]}) (init-lsp :rust_analyzer {:capabilities capabilities})) - -(init-lsp :tsserver {:root_dir (lsp.util.root_pattern "package.json")}) -(init-lsp :jsonls {:commands {:Format [ #(vim.lsp.buf.range_formatting [] [0 0] [(vim.fn.line "$") 0])]}}) -(init-lsp :denols {:root_dir (better_root_pattern [".git"] ["package.json"])}) -(init-lsp :hls {:settings {:languageServerHaskell {:formattingProvider "stylish-haskell"}}}) + +(init-lsp :tsserver {:root_dir (lsp.util.root_pattern "package.json")}) +(init-lsp :jsonls {:commands {:Format [ #(vim.lsp.buf.range_formatting [] [0 0] [(vim.fn.line "$") 0])]}}) +(init-lsp :denols {:root_dir (better_root_pattern [".git"] ["package.json"])}) +(init-lsp :hls {:settings {:languageServerHaskell {:formattingProvider "stylish-haskell"}}}) (init-lsp :ocamllsp) (init-lsp :vimls) (init-lsp :bashls) @@ -56,13 +56,25 @@ (init-lsp :html) (init-lsp :cssls) +(let [rust-tools (require "rust-tools")] + (rust-tools.setup {:tools {:inlay_hints {:show_parameter_hints false}}})) + +(let [sumneko_root_path (.. vim.env.HOME "/.local/share/lua-language-server") + sumneko_binary (.. sumneko_root_path "/bin/Linux/lua-language-server")] + (init-lsp + :sumneko_lua + {:cmd [sumneko_binary "-E" (.. sumneko_root_path "/main.lua")] + :settings {:Lua {:runtime {:version "LuaJIT" + :path (vim.split package.path ";")} + :diagnostics {:globals ["vim"]} + :workspace {:library {(vim.fn.expand "$VIMRUNTIME/lua") true + (vim.fn.expand "$VIMRUNTIME/lua/vim/lsp") true}} + :telemetry false}}})) + -;(lsp.vimls.setup { :on_attach on_attach}) (se signcolumn "yes") -;(let [rust-tools (require "rust-tools")] - ;(rust-tools.setup {:tools {:inlay_hints {:show_parameter_hints false}}})) - ; vim:foldmarker=<<<<<,>>>>> +; vim:foldmarker=<<<<<,>>>>>