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]
`(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)

View file

@ -49,7 +49,8 @@
(keymap.set :n :<leader>dtp :<cmd>TSPlaygroundToggle<CR>
{:desc "Toggle Treetsitter Playground"})
;; 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)
{:desc "Format Buffer"})
(keymap.set :n :<A-Left> :b)
@ -69,7 +70,8 @@
(keymap.set :x :gp "<Plug>(YankyGPutAfter)")
(keymap.set :x :gP "<Plug>(YankyGPutBefore)")
(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]
(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 {}
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)

View file

@ -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 @@
:<C-Space> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Insert
: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
: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}])

View file

@ -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