diff --git a/home/config/nvim/macros/cmd.fnl b/home/config/nvim/macros/cmd.fnl index efa751d..9e0c096 100644 --- a/home/config/nvim/macros/cmd.fnl +++ b/home/config/nvim/macros/cmd.fnl @@ -8,8 +8,14 @@ (fn mod.highlight-link [src dst] `(vim.api.nvim_cmd {:cmd :highlight :args [:link ,src ,dst]} [])) + (fn mod.highlight-get [name] + `(vim.api.nvim_get_hl 0 {:name ,name :link false})) + + (fn mod.highlight-get-field [name field] + `(. (vim.api.nvim_get_hl 0 {:name ,name :link false}) ,field)) + (fn mod.deferred_cmd [args delay] - `(vim.defer_fn #(vim.api.nvim_cmd ,args []) ,delay)) + `(vim.defer_fn #(vim.api.nvim_cmd ,args []) + ,delay)) mod) - diff --git a/home/config/nvim/nifoc/keymap.fnl b/home/config/nvim/nifoc/keymap.fnl index cd97aa8..e87c346 100644 --- a/home/config/nvim/nifoc/keymap.fnl +++ b/home/config/nvim/nifoc/keymap.fnl @@ -49,7 +49,8 @@ (keymap.set :n :dtp :TSPlaygroundToggle {:desc "Toggle Treetsitter Playground"}) ;; Other Mappings - (keymap.set :i : npairs.autopairs_cr {:expr true :silent true}) + (keymap.set :i : npairs.autopairs_cr + {:expr true :replace_keycodes false :silent true}) (keymap.set :n :F #(formatting.maybe-format-buffer 0) {:desc "Format Buffer"}) (keymap.set :n : :b) @@ -69,7 +70,8 @@ (keymap.set :x :gp "(YankyGPutAfter)") (keymap.set :x :gP "(YankyGPutBefore)") (keymap.set :n :y "(YankyYank)") - (keymap.set :x :y "(YankyYank)")) + (keymap.set :x :y "(YankyYank)") + (keymap.set :n "-" :Oil {:desc "Open Oil"})) (fn mod.lsp-attach [_client bufnr] (keymap.set :n :t diff --git a/home/config/nvim/nifoc/theme.fnl b/home/config/nvim/nifoc/theme.fnl index 708682f..4fb08a3 100644 --- a/home/config/nvim/nifoc/theme.fnl +++ b/home/config/nvim/nifoc/theme.fnl @@ -1,10 +1,16 @@ -(import-macros {: colorscheme : highlight : highlight-link} :../macros/cmd) +(import-macros {: colorscheme + : highlight + : highlight-link + : highlight-get-field} :../macros/cmd) (let [mod {} o vim.opt g vim.g dracula (require :dracula) dracula-colors (dracula.colors)] + (fn swap-bg-with-fg [fg group] + (highlight group {: fg :bg (highlight-get-field group :fg)})) + (set mod.colors dracula-colors) (fn mod.setup [] @@ -34,6 +40,39 @@ (highlight :RainbowDelimiterOrange {:fg mod.colors.orange}) (highlight :RainbowDelimiterGreen {:fg mod.colors.green}) (highlight :RainbowDelimiterViolet {:fg mod.colors.pink}) - (highlight :RainbowDelimiterCyan {:fg mod.colors.cyan})) + (highlight :RainbowDelimiterCyan {:fg mod.colors.cyan}) + ;; cmp + (highlight :CmpItemAbbr {:fg mod.colors.white :bg :NONE}) + (highlight :CmpItemAbbrMatch {:fg mod.colors.cyan :bg :NONE :bold true}) + (highlight :CmpItemAbbrMatchFuzzy + {:fg mod.colors.cyan :bg :NONE :bold true}) + (highlight :CmpItemMenu {:fg mod.colors.purple :bg :NONE :italic true}) + (let [cmp-groups [:CmpItemKindField + :CmpItemKindProperty + :CmpItemKindEvent + :CmpItemKindText + :CmpItemKindEnum + :CmpItemKindKeyword + :CmpItemKindConstant + :CmpItemKindConstructor + :CmpItemKindReference + :CmpItemKindFunction + :CmpItemKindStruct + :CmpItemKindClass + :CmpItemKindModule + :CmpItemKindOperator + :CmpItemKindVariable + :CmpItemKindFile + :CmpItemKindUnit + :CmpItemKindSnippet + :CmpItemKindFolder + :CmpItemKindMethod + :CmpItemKindValue + :CmpItemKindEnumMember + :CmpItemKindInterface + :CmpItemKindColor + :CmpItemKindTypeParameter]] + (each [_ group (pairs cmp-groups)] + (swap-bg-with-fg mod.colors.black group)))) mod) diff --git a/home/config/nvim/plugins/cmp.fnl b/home/config/nvim/plugins/cmp.fnl index 75b81e5..6eca9c0 100644 --- a/home/config/nvim/plugins/cmp.fnl +++ b/home/config/nvim/plugins/cmp.fnl @@ -22,7 +22,6 @@ (fallback))) (cmp.setup {:sources (cmp.config.sources [{:name :nvim_lsp} - ;{:name :nvim_lsp_signature_help} {:name :luasnip} {:name :treesitter :keyword_length 3} @@ -44,19 +43,28 @@ : (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Insert :select true}) : (cmp.mapping.confirm {:select true})}) - :window {:documentation (cmp.config.window.bordered)} + :window {:completion {:winhighlight "Normal:Pmenu,FloatBorder:Pmenu,Search:None" + :col_offset -3 + :side_padding 0} + :documentation (cmp.config.window.bordered)} + :view {:entries {:name :custom :selection_order :near_cursor}} :completion {:keyword_length 2 :completeopt "menu,menuone,noinsert"} :snippet {:expand (fn [args] (luasnip.lsp_expand args.body))} - :formatting {:format (lspkind.cmp_format {:mode :symbol_text - :menu {:buffer "[Buffer]" - :cmdline "[Cmd]" - :luasnip "[LuaSnip]" - :nvim_lsp "[LSP]" - :nvim_lsp_document_symbol "[Symbol]" - :nvim_lua "[Lua]" - :path "[Path]"}})}}) + :formatting {:fields [:kind :abbr :menu] + :format (fn [entry vim-item] + (let [kind-fn (lspkind.cmp_format {:mode :symbol_text + :maxwidth 50}) + kind (kind-fn entry vim-item) + strings (vim.split kind.kind "%s" + {:trimempty true})] + (set kind.kind + (.. " " (or (. strings 1) "") " ")) + (set kind.menu + (.. " (" (or (. strings 2) "") + ")")) + kind))}}) (cmp.setup.cmdline "/" {:sources (cmp.config.sources [{:name :nvim_lsp_document_symbol}] [{:name :buffer}]) diff --git a/home/config/nvim/plugins/lsp.fnl b/home/config/nvim/plugins/lsp.fnl index 39fc527..018a1d0 100644 --- a/home/config/nvim/plugins/lsp.fnl +++ b/home/config/nvim/plugins/lsp.fnl @@ -28,8 +28,12 @@ ;; Servers (vim.lsp.set_log_level :OFF) (let [capabilities (cmp.default_capabilities) + handlers {:textDocument/hover (vim.lsp.with vim.lsp.handlers.hover + {:border :rounded}) + :textDocument/signatureHelp (vim.lsp.with vim.lsp.handlers.signature_help + {:border :rounded})} flags {:allow_incremental_sync true :debounce_text_changes 700} - default-config {: capabilities : flags} + default-config {: capabilities : handlers : flags} default-servers [:bashls :cssls :dockerls