1
0
Fork 0

nvim: cmp styling/update

This commit is contained in:
Daniel Kempkens 2023-11-20 21:59:54 +01:00
parent e8840b1495
commit 4d06461aa9
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
5 changed files with 76 additions and 17 deletions

View file

@ -8,8 +8,14 @@
(fn mod.highlight-link [src dst] (fn mod.highlight-link [src dst]
`(vim.api.nvim_cmd {:cmd :highlight :args [: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] (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) mod)

View file

@ -49,7 +49,8 @@
(keymap.set :n :<leader>dtp :<cmd>TSPlaygroundToggle<CR> (keymap.set :n :<leader>dtp :<cmd>TSPlaygroundToggle<CR>
{:desc "Toggle Treetsitter Playground"}) {:desc "Toggle Treetsitter Playground"})
;; Other Mappings ;; Other Mappings
(keymap.set :i :<CR> npairs.autopairs_cr {:expr true :silent true}) (keymap.set :i :<CR> npairs.autopairs_cr
{:expr true :replace_keycodes false :silent true})
(keymap.set :n :F #(formatting.maybe-format-buffer 0) (keymap.set :n :F #(formatting.maybe-format-buffer 0)
{:desc "Format Buffer"}) {:desc "Format Buffer"})
(keymap.set :n :<A-Left> :b) (keymap.set :n :<A-Left> :b)
@ -69,7 +70,8 @@
(keymap.set :x :gp "<Plug>(YankyGPutAfter)") (keymap.set :x :gp "<Plug>(YankyGPutAfter)")
(keymap.set :x :gP "<Plug>(YankyGPutBefore)") (keymap.set :x :gP "<Plug>(YankyGPutBefore)")
(keymap.set :n :y "<Plug>(YankyYank)") (keymap.set :n :y "<Plug>(YankyYank)")
(keymap.set :x :y "<Plug>(YankyYank)")) (keymap.set :x :y "<Plug>(YankyYank)")
(keymap.set :n "-" :<cmd>Oil<CR> {:desc "Open Oil"}))
(fn mod.lsp-attach [_client bufnr] (fn mod.lsp-attach [_client bufnr]
(keymap.set :n :<leader>t (keymap.set :n :<leader>t

View file

@ -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 {} (let [mod {}
o vim.opt o vim.opt
g vim.g g vim.g
dracula (require :dracula) dracula (require :dracula)
dracula-colors (dracula.colors)] 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) (set mod.colors dracula-colors)
(fn mod.setup [] (fn mod.setup []
@ -34,6 +40,39 @@
(highlight :RainbowDelimiterOrange {:fg mod.colors.orange}) (highlight :RainbowDelimiterOrange {:fg mod.colors.orange})
(highlight :RainbowDelimiterGreen {:fg mod.colors.green}) (highlight :RainbowDelimiterGreen {:fg mod.colors.green})
(highlight :RainbowDelimiterViolet {:fg mod.colors.pink}) (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) mod)

View file

@ -22,7 +22,6 @@
(fallback))) (fallback)))
(cmp.setup {:sources (cmp.config.sources [{:name :nvim_lsp} (cmp.setup {:sources (cmp.config.sources [{:name :nvim_lsp}
;{:name :nvim_lsp_signature_help}
{:name :luasnip} {:name :luasnip}
{:name :treesitter {:name :treesitter
:keyword_length 3} :keyword_length 3}
@ -44,19 +43,28 @@
:<C-Space> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Insert :<C-Space> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Insert
:select true}) :select true})
:<CR> (cmp.mapping.confirm {:select true})}) :<CR> (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 :completion {:keyword_length 2
:completeopt "menu,menuone,noinsert"} :completeopt "menu,menuone,noinsert"}
:snippet {:expand (fn [args] :snippet {:expand (fn [args]
(luasnip.lsp_expand args.body))} (luasnip.lsp_expand args.body))}
:formatting {:format (lspkind.cmp_format {:mode :symbol_text :formatting {:fields [:kind :abbr :menu]
:menu {:buffer "[Buffer]" :format (fn [entry vim-item]
:cmdline "[Cmd]" (let [kind-fn (lspkind.cmp_format {:mode :symbol_text
:luasnip "[LuaSnip]" :maxwidth 50})
:nvim_lsp "[LSP]" kind (kind-fn entry vim-item)
:nvim_lsp_document_symbol "[Symbol]" strings (vim.split kind.kind "%s"
:nvim_lua "[Lua]" {:trimempty true})]
:path "[Path]"}})}}) (set kind.kind
(.. " " (or (. strings 1) "") " "))
(set kind.menu
(.. " (" (or (. strings 2) "")
")"))
kind))}})
(cmp.setup.cmdline "/" (cmp.setup.cmdline "/"
{:sources (cmp.config.sources [{:name :nvim_lsp_document_symbol}] {:sources (cmp.config.sources [{:name :nvim_lsp_document_symbol}]
[{:name :buffer}]) [{:name :buffer}])

View file

@ -28,8 +28,12 @@
;; Servers ;; Servers
(vim.lsp.set_log_level :OFF) (vim.lsp.set_log_level :OFF)
(let [capabilities (cmp.default_capabilities) (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} flags {:allow_incremental_sync true :debounce_text_changes 700}
default-config {: capabilities : flags} default-config {: capabilities : handlers : flags}
default-servers [:bashls default-servers [:bashls
:cssls :cssls
:dockerls :dockerls