From eb3ce80e7d8f5b0a52919092027f199c5236a35e Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Wed, 8 Feb 2023 21:45:02 -0800 Subject: [PATCH] Changed completion's for the cmdline --- fnl/plugin/cmp.fnl | 88 ++++++++++++++++++++++++++++++++++++++++++---- fnl/plugin/lsp.fnl | 4 +-- 2 files changed, 83 insertions(+), 9 deletions(-) diff --git a/fnl/plugin/cmp.fnl b/fnl/plugin/cmp.fnl index 889108f..34fd134 100644 --- a/fnl/plugin/cmp.fnl +++ b/fnl/plugin/cmp.fnl @@ -16,7 +16,7 @@ [ :i :c ]) : (cmp.mapping (cmp.mapping.abort) [ :i :c ]) - : (cmp.mapping + : (cmp.mapping (cmp.mapping.confirm { :select false }) [ :i :c ]) : (cmp.mapping @@ -59,6 +59,8 @@ { :name "treesitter" :priority 1 :group 2 } { :name "buffer" :priority 0 :group 3 } { :name "path" :priority 0 :group 4 }] + :view { + :entries { :name "custom" :selection_order "near_cursor" }} :sorting { :priority_weight 2 :comparators [ @@ -75,17 +77,89 @@ ]}}) (cmp.setup.filetype [ :lisp ] { :option { :fuzzy false } - :sources + :sources [{ :name "vlime" :priority 2 :group 1 } { :name "snippy" :priority 2 :group 2 } { :name "buffer" :priority 0 :group 3 } { :name "path" :priority 0 :group 4 }]}) + (let [cmdline-mappings + { : (cmp.mapping (cmp.mapping.complete) + [ :i :c ]) + : (cmp.mapping (cmp.mapping.abort) + [ :i :c ]) + : (cmp.mapping + (cmp.mapping.confirm { :select false }) + [ :i :c ]) + : (cmp.mapping + (fn [] + (if (cmp.visible) + (cmp.select_next_item) + (do + (cmp.complete) + (cmp.complete_common_string)))) + [ :i :c ]) + : (cmp.mapping + (fn [] + (if (cmp.visible) + (cmp.select_prev_item) + (do + (cmp.complete) + (cmp.complete_common_string)))) + [ :i :c ]) + : (cmp.mapping + (fn [] + (if (cmp.visible) + (cmp.select_next_item + { :behavior cmp.SelectBehavior.Select }) + (vim.api.nvim_feedkeys + (vim.api.nvim_replace_termcodes : + true + false + true) + :n false))) + [ :i :c ]) + : (cmp.mapping + (fn [] + (if (cmp.visible) + (cmp.select_prev_item + { :behavior cmp.SelectBehavior.Select }) + (vim.api.nvim_feedkeys + (vim.api.nvim_replace_termcodes : + true + false + true) + :n false))) + [ :i :c ]) + : (cmp.mapping + (cmp.mapping.select_next_item + { :behavior cmp.SelectBehavior.Select }) + [ :i :c ]) + : (cmp.mapping + (cmp.mapping.select_prev_item + { :behavior cmp.SelectBehavior.Select }) + [ :i :c ]) + : (cmp.mapping + (fn [fallback] + (if (cmp.visible) + (cmp.select_next_item + { :behavior cmp.SelectBehavior.Select }) + (fallback))) + [ :i :c ]) + : (cmp.mapping + (fn [fallback] + (if (cmp.visible) + (cmp.select_prev_item + { :behavior cmp.SelectBehavior.Select }) + (fallback))) + [ :i :c ])}] (cmp.setup.cmdline "/" - { :mapping (cmp.mapping.preset.cmdline) + { :completion { :autocomplete true } + :mapping cmdline-mappings :sources (cmp.config.sources [{ :name "buffer" }])}) (cmp.setup.cmdline ":" - { :mapping (cmp.mapping.preset.cmdline) - :sources (cmp.config.sources - [{ :name "cmdline" } - { :name "path" }])}))} + { :completion { :autocomplete false } + :mapping cmdline-mappings + :sources (cmp.config.sources + [{ :name "cmdline" } + { :name "path" }])})))} diff --git a/fnl/plugin/lsp.fnl b/fnl/plugin/lsp.fnl index 049fe67..322ce52 100644 --- a/fnl/plugin/lsp.fnl +++ b/fnl/plugin/lsp.fnl @@ -38,8 +38,8 @@ (bind! :n :D "Telescope lsp_type_definitions" buf) ;; Some trouble commands - (bind! :n :e "TroubleToggle document_diagnostics") - (bind! :n :E "TroubleToggle workspace_diagnostics")) + (bind! :n :q "TroubleToggle document_diagnostics") + (bind! :n :Q "TroubleToggle workspace_diagnostics")) (fn get-data-dir [server root]