This repository has been archived on 2024-10-28. You can view files and clone it, but cannot push or open issues or pull requests.
nvim-config/fnl/plugin/cmp.fnl

169 lines
7.1 KiB
Plaintext
Raw Normal View History

2022-11-30 23:29:58 -08:00
;;; cmp.fnl - nvim-cmp config
(import-macros {: module-call!} :macros)
{ :configure #(let [cmp (require :cmp)
compare (require :cmp.config.compare)]
2022-12-07 03:39:47 -08:00
(cmp.setup
{ :snippet {
:expand #(module-call! :snippy :expand_snippet $1.body) }
:mapping {
:<C-b> (cmp.mapping (cmp.mapping.scroll_docs -4)
[ :i :c ])
:<C-f> (cmp.mapping (cmp.mapping.scroll_docs 4)
[ :i :c ])
:<C-space> (cmp.mapping (cmp.mapping.complete)
[ :i :c ])
:<C-e> (cmp.mapping (cmp.mapping.abort)
[ :i :c ])
2023-02-08 21:45:02 -08:00
:<cr> (cmp.mapping
2022-12-07 03:39:47 -08:00
(cmp.mapping.confirm { :select false })
2022-11-30 23:29:58 -08:00
[ :i :c ])
2022-12-07 03:39:47 -08:00
:<C-j> (cmp.mapping
(cmp.mapping.select_next_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<C-k> (cmp.mapping
(cmp.mapping.select_prev_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<C-n> (cmp.mapping
(cmp.mapping.select_next_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<C-p> (cmp.mapping
(cmp.mapping.select_prev_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<down> (cmp.mapping
(cmp.mapping.select_next_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<up> (cmp.mapping
(cmp.mapping.select_prev_item
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ]) }
:formatting {
:format (fn [entry vim_item]
(tset vim_item :menu
(. { :nvim_lsp "[LSP]"
:treesitter "[TS]"
:snippy "[Snippy]"
:buffer "[Buffer]"
:path "[Path]"
:vlime "[Vlime]" }
entry.source.name))
vim_item)
}
:sources [{ :name "snippy" :priority 2 :group 1 }
{ :name "treesitter" :priority 1 :group 2 }
{ :name "buffer" :priority 0 :group 3 }
{ :name "path" :priority 0 :group 4 }]
2023-02-08 21:45:02 -08:00
:view {
2023-02-23 11:41:01 -08:00
:entries {
:name "custom"
; :selection_order "near_cursor"
}}
2022-12-07 03:39:47 -08:00
:sorting {
:priority_weight 2
:comparators [
compare.score
compare.locality
compare.recently_used
compare.offset
compare.order
; compare.scopes
; compare.exact
; compare.sort_text
; compare.kind
; compare.length
]}})
(cmp.setup.filetype [ :lisp ]
{ :option { :fuzzy false }
2023-02-08 21:45:02 -08:00
:sources
2022-12-07 03:39:47 -08:00
[{ :name "vlime" :priority 2 :group 1 }
{ :name "snippy" :priority 2 :group 2 }
{ :name "buffer" :priority 0 :group 3 }
{ :name "path" :priority 0 :group 4 }]})
2023-02-08 21:45:02 -08:00
(let [cmdline-mappings
{ :<C-space> (cmp.mapping (cmp.mapping.complete)
[ :i :c ])
:<C-e> (cmp.mapping (cmp.mapping.abort)
[ :i :c ])
:<cr> (cmp.mapping
(cmp.mapping.confirm { :select false })
[ :i :c ])
:<Tab> (cmp.mapping
(fn []
(if (cmp.visible)
2023-02-23 11:41:01 -08:00
(cmp.select_prev_item)
2023-02-08 21:45:02 -08:00
(do
(cmp.complete)
(cmp.complete_common_string))))
[ :i :c ])
:<S-Tab> (cmp.mapping
(fn []
(if (cmp.visible)
2023-02-23 11:41:01 -08:00
(cmp.select_next_item)
2023-02-08 21:45:02 -08:00
(do
(cmp.complete)
(cmp.complete_common_string))))
[ :i :c ])
:<C-k> (cmp.mapping
(fn []
(if (cmp.visible)
2023-02-23 11:41:01 -08:00
(cmp.select_prev_item
2023-02-08 21:45:02 -08:00
{ :behavior cmp.SelectBehavior.Select })
(vim.api.nvim_feedkeys
(vim.api.nvim_replace_termcodes :<up>
true
false
true)
:n false)))
[ :i :c ])
:<C-j> (cmp.mapping
(fn []
(if (cmp.visible)
2023-02-23 11:41:01 -08:00
(cmp.select_next_item
2023-02-08 21:45:02 -08:00
{ :behavior cmp.SelectBehavior.Select })
(vim.api.nvim_feedkeys
(vim.api.nvim_replace_termcodes :<down>
true
false
true)
:n false)))
[ :i :c ])
:<C-p> (cmp.mapping
2023-02-23 11:41:01 -08:00
(cmp.mapping.select_prev_item
2023-02-08 21:45:02 -08:00
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<C-n> (cmp.mapping
2023-02-23 11:41:01 -08:00
(cmp.mapping.select_next_item
2023-02-08 21:45:02 -08:00
{ :behavior cmp.SelectBehavior.Select })
[ :i :c ])
:<up> (cmp.mapping
(fn [fallback]
(if (cmp.visible)
2023-02-23 11:41:01 -08:00
(cmp.select_prev_item
2023-02-08 21:45:02 -08:00
{ :behavior cmp.SelectBehavior.Select })
(fallback)))
[ :i :c ])
:<down> (cmp.mapping
(fn [fallback]
(if (cmp.visible)
2023-02-23 11:41:01 -08:00
(cmp.select_next_item
2023-02-08 21:45:02 -08:00
{ :behavior cmp.SelectBehavior.Select })
(fallback)))
[ :i :c ])}]
2022-11-30 23:29:58 -08:00
(cmp.setup.cmdline "/"
2023-02-08 21:45:02 -08:00
{ :completion { :autocomplete true }
:mapping cmdline-mappings
2022-11-30 23:29:58 -08:00
:sources (cmp.config.sources
[{ :name "buffer" }])})
(cmp.setup.cmdline ":"
2023-02-08 21:45:02 -08:00
{ :completion { :autocomplete false }
:mapping cmdline-mappings
:sources (cmp.config.sources
[{ :name "cmdline" }
{ :name "path" }])})))}