From f46a8231a069fd5a29f171508676a0eb63f0ec0b Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Sat, 9 Oct 2021 13:26:38 +0200 Subject: [PATCH] Add some cmp stuff to vim --- nvim/.config/nvim/fnl/dots/plugins.fnl | 29 +++++++++++++------ nvim/.config/nvim/fnl/dots/plugins/cmp.fnl | 26 +++++++++++++++-- .../nvim/fnl/dots/plugins/telescope.fnl | 4 +-- nvim/.config/nvim/fnl/init.fnl | 3 ++ 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/nvim/.config/nvim/fnl/dots/plugins.fnl b/nvim/.config/nvim/fnl/dots/plugins.fnl index 0b77d81..6a13419 100644 --- a/nvim/.config/nvim/fnl/dots/plugins.fnl +++ b/nvim/.config/nvim/fnl/dots/plugins.fnl @@ -14,15 +14,16 @@ (defn use [...] (let [pkgs [...]] (packer.startup - (fn [use] - (for [i 1 (a.count pkgs) 2] - (let [name (. pkgs i) - opts (. pkgs (+ i 1))] - (-?> (. opts :mod) (safe-req-conf)) - (use (a.assoc opts 1 name)))))))) - - + {1 (fn [use] + (for [i 1 (a.count pkgs) 2] + (let [name (. pkgs i) + opts (. pkgs (+ i 1))] + (-?> (. opts :mod) (safe-req-conf)) + (use (a.assoc opts 1 name))))) + :config {:compile_path (.. (vim.fn.stdpath "config") "/lua/packer_compiled.lua")}}))) + (use + :lewis6991/impatient.nvim {} :elkowar/yuck.vim {} :nvim-lua/plenary.nvim {} :elkowar/antifennel-nvim {:opt false :config #(set vim.g.antifennel_executable "/home/leon/tmp/antifennel/antifennel")} @@ -161,11 +162,19 @@ :hrsh7th/cmp-vsnip {} :hrsh7th/cmp-nvim-lsp {} :hrsh7th/cmp-buffer {} + :hrsh7th/cmp-path {} + :hrsh7th/cmp-nvim-lua {} + :hrsh7th/cmp-calc {} :hrsh7th/nvim-cmp {:opt false :requires [:hrsh7th/cmp-nvim-lsp :hrsh7th/cmp-buffer - :hrsh7th/cmp-vsnip] + :hrsh7th/cmp-vsnip + :hrsh7th/cmp-nvim-lua + :hrsh7th/cmp-calc + :hrsh7th/cmp-path] + + :config #(require "dots.plugins.cmp")} @@ -223,6 +232,8 @@ :bakpakin/fennel.vim {} :evanleck/vim-svelte {}) +(require "packer_compiled") + ; >>> diff --git a/nvim/.config/nvim/fnl/dots/plugins/cmp.fnl b/nvim/.config/nvim/fnl/dots/plugins/cmp.fnl index ff104ff..f8af042 100644 --- a/nvim/.config/nvim/fnl/dots/plugins/cmp.fnl +++ b/nvim/.config/nvim/fnl/dots/plugins/cmp.fnl @@ -2,18 +2,39 @@ {autoload {a aniseed.core cmp cmp}}) +; check this for coloring maybe +; https://github.com/hrsh7th/nvim-cmp/blob/ada9ddeff71e82ad0e52c9a280a1e315a8810b9a/lua/cmp/entry.lua#L199 +(defn item-formatter [item vim-item] + (let [padding (string.rep " " (- 10 (vim.fn.strwidth vim-item.abbr))) + details (?. item :completion_item :detail)] + (when details + (set vim-item.abbr (.. vim-item.abbr padding " " details)))) + vim-item) + + (cmp.setup - {:snippet {:expand (fn [args] - ((. vim.fn :vsnip#anonymous) args.body))} + {:snippet {:expand (fn [args] ((. vim.fn :vsnip#anonymous) args.body))} + + :completion {:autocomplete false} + :mapping {: (cmp.mapping.scroll_docs -4) : (cmp.mapping.scroll_docs 4) : (cmp.mapping.complete) : #(do (cmp.mapping.close) (vim.cmd "stopinsert")) : (cmp.mapping.confirm {:select true})} + + ;:experimental {:custom_menu true} + :sources [{:name "nvim_lsp" :priority 5} {:name "vsnip" :priority 3} + {:name "nvim_lua"} + {:name "calc"} + {:name "path"} {:name "crates"}] ;{:name "buffer"}] + + :formatting {:format item-formatter} + :sorting {:comparators [#(do ;(print ($1:get_kind) $1.completion_item.label "--" ($2:get_kind) $2.completion_item.label) (if (= 15 ($1:get_kind)) false nil)) ; 15 means "SNIPPET", see https://github.com/hrsh7th/nvim-cmp/blob/main/lua/cmp/types/lsp.lua @@ -25,3 +46,4 @@ cmp.config.compare.length cmp.config.compare.order]}}) + diff --git a/nvim/.config/nvim/fnl/dots/plugins/telescope.fnl b/nvim/.config/nvim/fnl/dots/plugins/telescope.fnl index 1c628eb..ce6607d 100644 --- a/nvim/.config/nvim/fnl/dots/plugins/telescope.fnl +++ b/nvim/.config/nvim/fnl/dots/plugins/telescope.fnl @@ -5,10 +5,8 @@ (telescope.setup {:defaults {:mappings {:i {: actions.close}} - :file_ignore_patterns ["Cargo.lock" ".*.snap" "docs/theme/.*"]} - :extensions {:frecency {:persistent_filter false}}}) + :file_ignore_patterns ["Cargo.lock" ".*.snap" "docs/theme/.*"]}}) -(telescope.load_extension "frecency") (telescope.load_extension "dap") (telescope.load_extension "packer") diff --git a/nvim/.config/nvim/fnl/init.fnl b/nvim/.config/nvim/fnl/init.fnl index 6067559..4ffd453 100644 --- a/nvim/.config/nvim/fnl/init.fnl +++ b/nvim/.config/nvim/fnl/init.fnl @@ -7,6 +7,7 @@ colors dots.colors} require-macros [macros]}) + (macro make-errors-epic [f] `(xpcall #,f #(let [fennel# (require :aniseed.fennel)] (a.println (fennel#.traceback $1))))) @@ -16,6 +17,8 @@ (make-errors-epic (require "dots.plugins")) +(require "impatient") + (make-errors-epic (require "dots.plugins.lsp")) (make-errors-epic (require "dots.keybinds"))