From b5045205739866af250cf5fbbbe629f88800a533 Mon Sep 17 00:00:00 2001 From: Proctor Date: Mon, 17 Oct 2022 15:47:01 -0500 Subject: [PATCH] Misc package updates plus lots of fnlfmt updates --- nvim/.config/nvim/fnl/dotfiles/mapping.fnl | 32 ++-- nvim/.config/nvim/fnl/dotfiles/plugin/cmp.fnl | 48 +++-- .../nvim/fnl/dotfiles/plugin/lspconfig.fnl | 62 +++---- .../nvim/fnl/dotfiles/plugin/luasnip.fnl | 19 ++ nvim/.config/nvim/fnl/dotfiles/plugins.fnl | 165 +++++++++--------- 5 files changed, 167 insertions(+), 159 deletions(-) create mode 100644 nvim/.config/nvim/fnl/dotfiles/plugin/luasnip.fnl diff --git a/nvim/.config/nvim/fnl/dotfiles/mapping.fnl b/nvim/.config/nvim/fnl/dotfiles/mapping.fnl index f0a1732..3e37050 100644 --- a/nvim/.config/nvim/fnl/dotfiles/mapping.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/mapping.fnl @@ -1,41 +1,38 @@ (module dotfiles.mapping - {autoload {nvim aniseed.nvim - nu aniseed.nvim.util - core aniseed.core - util dotfiles.util - }}) + {autoload {nvim aniseed.nvim + nu aniseed.nvim.util + core aniseed.core + util dotfiles.util}}) -(defn- noremap [mode from to] - "Sets a mapping with {:noremap true}." - (nvim.set_keymap mode from to {:noremap true})) +(defn- noremap [mode from to] "Sets a mapping with {:noremap true}." + (nvim.set_keymap mode from to {:noremap true})) ; (set nvim.g.mapleader "\\") (noremap :n "`" ":source ~/.config/nvim/init.lua") -(noremap :n "!" ":call AniseedCompile()") +(noremap :n :! ":call AniseedCompile()") (noremap :n : ":nohlsearch/") ;; Correct to first spelling suggestion. (noremap :n :zz ":normal! 1z=") - ;; nice paste from clipboard in insert mode (noremap :i : ":set paste+:set nopaste") - ; Insert Date (noremap :n : "\"=strftime(\"%F\")p") (noremap :i : "=strftime(\"%F\")") ; Make markdown link with empty url ;map ah S -(noremap :v :ah "S") +(noremap :v :ah + "S") + (noremap :v :ml "xi[\"]()") - -(noremap :n : "3") -(noremap :n : "3") +(noremap :n : :3) +(noremap :n : :3) ; Unimpaired configuration ; Bubble single lines @@ -56,8 +53,9 @@ (noremap :n :gsh ":GitGutterStageHunk") ; Open file in Marked 2 (markdown viewer) -(noremap :n :mv ":AsyncRun -mode=bang open -a Marked\\ 2.app \'%:p\'") +(noremap :n :mv ":AsyncRun -mode=bang open -a Marked\\ 2.app '%:p'") ; Run current statement in DadBod-UI -(nvim.ex.autocmd :FileType :sql :nmap :s "vapS") +(nvim.ex.autocmd :FileType :sql :nmap :s :vapS) +(noremap :n :Q ":.!bash ") diff --git a/nvim/.config/nvim/fnl/dotfiles/plugin/cmp.fnl b/nvim/.config/nvim/fnl/dotfiles/plugin/cmp.fnl index ec99082..5188038 100644 --- a/nvim/.config/nvim/fnl/dotfiles/plugin/cmp.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/plugin/cmp.fnl @@ -1,45 +1,39 @@ -(module dotfiles.plugin.cmp - {autoload {nvim aniseed.nvim}}) +(module dotfiles.plugin.cmp {autoload {nvim aniseed.nvim luasnip luasnip}}) +(module config.plugin.cmp {autoload {nvim aniseed.nvim cmp cmp}}) -(module config.plugin.cmp - {autoload {nvim aniseed.nvim - cmp cmp}}) +(def- cmp-src-menu-items {:buffer :buff :conjure :conj :nvim_lsp :lsp}) -(def- cmp-src-menu-items - {:buffer "buff" - :conjure "conj" - :nvim_lsp "lsp"}) - -(def- cmp-srcs - [{:name :nvim_lsp} - {:name :nvim_lua} - {:name :vsnip} - {:name :conjure} - {:name :buffer} - {:name :orgmode} - {:name :emoji :max_item_count 8}]) +(def- cmp-srcs [{:name :nvim_lsp} + {:name :nvim_lua} + {:name :luasnip} + {:name :vsnip} + {:name :conjure} + {:name :buffer} + {:name :orgmode} + {:name :emoji :max_item_count 8}]) ;; Setup cmp with desired settings (let [cmp (require :cmp)] - (cmp.setup {:formatting - {:format (fn [entry item] - (set item.menu (or (. cmp-src-menu-items entry.source.name) "")) - item)} + (cmp.setup {:formatting {:format (fn [entry item] + (set item.menu + (or (. cmp-src-menu-items + entry.source.name) + "")) + item)} :mapping {: (cmp.mapping.select_prev_item) : (cmp.mapping.select_next_item) : (cmp.mapping.scroll_docs (- 4)) : (cmp.mapping.scroll_docs 4) : (cmp.mapping.complete) : (cmp.mapping.close) - : (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Insert - :select true})} - + : (cmp.mapping.confirm {;; :behavior cmp.ConfirmBehavior.Insert + :select true})} :snippet {:expand (fn [args] - (nvim.fn.vsnip#anonymous args.body))} + (if args + (luasnip.lsp_expand args.body)))} :sources cmp-srcs})) - ;;; imap vsnip#available(1) ? '(vsnip-expand)' : '' ;;; imap vsnip#available(1) ? '(vsnip-expand-or-jump)' : '' ;;; smap vsnip#available(1) ? '(vsnip-expand-or-jump)' : '' diff --git a/nvim/.config/nvim/fnl/dotfiles/plugin/lspconfig.fnl b/nvim/.config/nvim/fnl/dotfiles/plugin/lspconfig.fnl index 486e0f4..fe4aa9e 100644 --- a/nvim/.config/nvim/fnl/dotfiles/plugin/lspconfig.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/plugin/lspconfig.fnl @@ -2,7 +2,9 @@ {autoload {a aniseed.core u dotfiles.util nvim aniseed.nvim - nu aniseed.nvim.util}}) + lsp vim.lsp + nu aniseed.nvim.util + cmp_nvim_lsp cmp_nvim_lsp}}) (defn bufmap [mode from to] (u.noremap mode from to {:local? true})) @@ -32,7 +34,7 @@ :K "lua vim.lsp.buf.hover()" "[g" "lua vim.diagnostic.goto_prev()" "]g" "lua vim.diagnostic.goto_next()" - : "lua vim.lsp.buf.signature_help()" + ;: "lua vim.lsp.buf.signature_help()" :ca "lua vim.lsp.buf.code_action()" :cl "lua vim.lsp.codelens.run()" :ic "lua vim.lsp.buf.incoming_calls()" @@ -115,39 +117,39 @@ ; -- buf_set_keymap('x', 'ic', "lua vim.lsp.buf.incoming_calls()", opts) (nvim.buf_set_option 0 :omnifunc "v:lua.vim.lsp.omnifunc") (bind-client-mappings client) - (nvim.ex.autocmd :BufWritePre : :lua - "vim.lsp.buf.formatting_sync()") + (nvim.ex.autocmd :BufWritePre : :lua :vim.lsp.buf.format) ; (nvim.ex.autocmd "BufEnter,CursorHold,InsertLeave" : :lua "vim.lsp.codelens.refresh()") ; client autocmds ; -- vim.api.nvim_command[[autocmd BufWritePre lua vim.lsp.buf_request_sync(vim.api.nvim_get_current_buf(), 'workspace/executeCommand', {command = 'clean-ns', arguments = {vim.uri_from_bufnr(1), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]] (print "LSP Client Attached.")) -(let [lspi (require :nvim-lsp-installer)] - (when lspi - (defn lsp-execute-command [cmd ...] - (let [buf-uri (vim.uri_from_bufnr 0) - cursor (vim.api.nvim_win_get_cursor 0) - r (- (a.first cursor) 1) - c (a.second cursor) - opts [buf-uri r c] - args (a.concat opts [...])] - (vim.lsp.buf.execute_command {:command cmd :arguments args}))) - (defn setup-servers [] - (lspi.on_server_ready (fn [server] - (let [opts {: on_attach - :flags {:debounce_text_changes 150}}] - (server:setup opts)))) - ;; (let [lspconfig (require :lspconfig) - ;; servers (lspi.get_installed_servers)] - ;; (each [_ server (pairs servers)] - ;; (server.setup {:on_attach on_attach :flags {:debounce_text_changes 150} }))) - ) - (defn on-post-install [] (setup-servers) (nvim.ex.bufdo :e)) - (setup-servers) - (set lspi.post_install_hook on-post-install) - (nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig - :lsp-execute-command {:return false}) - (u.nnoremap :li :LspInfo))) +(when-let [lspi (require :nvim-lsp-installer)] + (let [capabilities (cmp_nvim_lsp.update_capabilities (lsp.protocol.make_client_capabilities))] + (defn lsp-execute-command [cmd ...] + (let [buf-uri (vim.uri_from_bufnr 0) + cursor (vim.api.nvim_win_get_cursor 0) + r (- (a.first cursor) 1) + c (a.second cursor) + opts [buf-uri r c] + args (a.concat opts [...])] + (vim.lsp.buf.execute_command {:command cmd :arguments args}))) + (defn setup-servers [] + (lspi.on_server_ready (fn [server] + (let [opts {: on_attach + : capabilities + :flags {:debounce_text_changes 150}}] + (server:setup opts)))) + ;; (let [lspconfig (require :lspconfig) + ;; servers (lspi.get_installed_servers)] + ;; (each [_ server (pairs servers)] + ;; (server.setup {:on_attach on_attach :flags {:debounce_text_changes 150} }))) + ) + (defn on-post-install [] (setup-servers) (nvim.ex.bufdo :e)) + (setup-servers) + (set lspi.post_install_hook on-post-install) + (nu.fn-bridge :LspExecuteCommand :dotfiles.plugin.lspconfig + :lsp-execute-command {:return false}) + (u.nnoremap :li :LspInfo))) (comment (let [lspi (require :nvim-lsp-installer) ;lspconfig (require :lspconfig) diff --git a/nvim/.config/nvim/fnl/dotfiles/plugin/luasnip.fnl b/nvim/.config/nvim/fnl/dotfiles/plugin/luasnip.fnl new file mode 100644 index 0000000..3fa71cb --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/plugin/luasnip.fnl @@ -0,0 +1,19 @@ +(module dotfiles.plugin.luasnip + {autoload {nvim aniseed.nvim util dotfiles.util luasnip luasnip} + require {select_choice luasnip.extras.select_choice}}) + +(vim.keymap.set [:i :s] : + (fn [] + (if (luasnip.expand_or_jumpable) + (luasnip.expand_or_jump))) {:silent true}) + +(vim.keymap.set [:i :s] : + (fn [] + (if (luasnip.jumpable -1) + (luasnip.jump -1))) {:silent true}) + +(vim.keymap.set :i : (fn [] + (if (luasnip.choice_active) + (luasnip.choice 1)))) + +(vim.keymap.set :i : select_choice) diff --git a/nvim/.config/nvim/fnl/dotfiles/plugins.fnl b/nvim/.config/nvim/fnl/dotfiles/plugins.fnl index d711f40..e8ccf7b 100644 --- a/nvim/.config/nvim/fnl/dotfiles/plugins.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/plugins.fnl @@ -1,97 +1,92 @@ -(module dotfiles.plugins - {autoload {nvim aniseed.nvim - a aniseed.core - ;; util dotfiles.util - packer packer} - ;; require {minpac minpac} - }) - +(module dotfiles.plugins {autoload {nvim aniseed.nvim + a aniseed.core + ;; util dotfiles.util + packer packer} + ;; require {minpac minpac} + }) (defn safe-require-plugin-config [name] - (let [(ok? val-or-err) (pcall require (.. :dotfiles.plugin. name))] - (when (not ok?) - (print (.. "dotfiles error: " val-or-err))))) + (let [(ok? val-or-err) (pcall require (.. :dotfiles.plugin. name))] + (when (not ok?) + (print (.. "dotfiles error: " val-or-err))))) -(defn- use [pkgs] - "Iterates through the arguments as pairs and calls packer's use function for +(defn- use [pkgs] "Iterates through the arguments as pairs and calls packer's use function for each of them. Works around Fennel not liking mixed associative and sequential tables as well." - (packer.startup - (fn [use] - (each [name opts (pairs pkgs)] - (-?> (. opts :mod) (safe-require-plugin-config)) - (use (a.assoc opts 1 name)) - )))) + (packer.startup (fn [use] + (each [name opts (pairs pkgs)] + (-?> (. opts :mod) (safe-require-plugin-config)) + (use (a.assoc opts 1 name)))))) - -(def- packages - { - :Olical/aniseed {} - :Olical/conjure { :mod :conjure } ; Clojure - :Olical/fennel.vim {} ; Fennel - :airblade/vim-gitgutter {} ; Git - :airblade/vim-gitgutter {} ; Git - :akinsho/org-bullets.nvim {:mod :orgbullets} - :clojure-vim/vim-jack-in {} ; Conjure support - jack-in with nrepl dependencies - :dhruvasagar/vim-table-mode {} ; table creation and formatting - :folke/lsp-colors.nvim {} - :folke/which-key.nvim {:mod :whichkey} - :hashivim/vim-terraform {} ; Terraform - :hrsh7th/nvim-cmp {:requires [:hrsh7th/cmp-buffer - :hrsh7th/cmp-emoji - :hrsh7th/cmp-nvim-lsp - :hrsh7th/cmp-nvim-lua - :hrsh7th/cmp-path - :hrsh7th/cmp-vsnip - :hrsh7th/vim-vsnip-integ - :PaterJason/cmp-conjure] - :mod :cmp} ; autocomplete - :hrsh7th/vim-vsnip {} - :hrsh7th/vim-vsnip-integ {} - :Iron-E/nvim-soluarized {} - :jiangmiao/auto-pairs {} ; backets, parens, and quotes in pairs - :jose-elias-alvarez/null-ls.nvim {:mod :null-ls - :requires [:nvim-lua/plenary.nvim]} - :junegunn/vim-easy-align {:mod :easyalign} - :kovisoft/paredit {:mod :paredit} - :kristijanhusak/vim-dadbod-completion {} - :kristijanhusak/vim-dadbod-ui {} - :lukas-reineke/headlines.nvim {:mod :headlines} -; :michaelb/sniprun {:run "bash ./install.sh" :mod :sniprun} - :neovim/nvim-lspconfig {:mod :lspconfig} ; NeoVim lsp config - :norcalli/nvim-colorizer.lua {:mod :colorizer} - :nvim-orgmode/orgmode { :mod :orgmode } - :nvim-telescope/telescope.nvim {:requires [[:nvim-lua/popup.nvim] [:nvim-lua/plenary.nvim]] :mod :telescope} - :nvim-treesitter/nvim-treesitter {:run ":TSUpdate" :mod :treesitter} - :nvim-treesitter/playground {} - :p00f/nvim-ts-rainbow {} - :radenling/vim-dispatch-neovim {} ; Clojure - :skywind3000/asyncrun.vim {} ; :AsyncRun - :tpope/vim-classpath {} - :tpope/vim-dadbod {} - :tpope/vim-dispatch {} ; Conjure support - jack-in with nrepl dependencies - :tpope/vim-fugitive {:mod :fugitive} ; Git - :tpope/vim-git {} ; Git Commit Message - :tpope/vim-pathogen {} - :tpope/vim-rails {} - :tpope/vim-repeat {} - :tpope/vim-surround {} - :tpope/vim-unimpaired {} - :tpope/vim-vinegar {} - :wbthomason/packer.nvim {:mod :packer} - :williamboman/nvim-lsp-installer {} ; NeoVim lsp server installs - - ; :luochen1990/rainbow {} - ; :thecontinium/asyncomplete-conjure.vim {} - } - -; :tpope/vim-fireplace {} ; Clojure -; :tpope/vim-sexp-mappings-for-regular-people {} - ) +(def- packages {:Olical/aniseed {} + :Olical/conjure {:mod :conjure} + :Olical/fennel.vim {} + :airblade/vim-gitgutter {} + :akinsho/org-bullets.nvim {:mod :orgbullets} + :clojure-vim/vim-jack-in {} + :dhruvasagar/vim-table-mode {} + :folke/lsp-colors.nvim {} + :folke/which-key.nvim {:mod :whichkey} + :hashivim/vim-terraform {} + :hrsh7th/nvim-cmp {:requires [:hrsh7th/cmp-buffer + :hrsh7th/cmp-emoji + :hrsh7th/cmp-nvim-lsp + :hrsh7th/cmp-nvim-lua + :hrsh7th/cmp-path + :hrsh7th/cmp-vsnip + :hrsh7th/vim-vsnip-integ + :L3MON4D3/LuaSnip + :PaterJason/cmp-conjure + :saadparwaiz1/cmp_luasnip] + :mod :cmp} + :hrsh7th/vim-vsnip {} + :hrsh7th/vim-vsnip-integ {} + :Iron-E/nvim-soluarized {} + :jiangmiao/auto-pairs {} + :jose-elias-alvarez/null-ls.nvim {:mod :null-ls + :requires [:nvim-lua/plenary.nvim]} + :junegunn/vim-easy-align {:mod :easyalign} + :kovisoft/paredit {:mod :paredit} + :kristijanhusak/vim-dadbod-completion {} + :kristijanhusak/vim-dadbod-ui {} + :L3MON4D3/LuaSnip {:mod :luasnip} + :lukas-reineke/headlines.nvim {:mod :headlines} + ; :michaelb/sniprun {:run "bash ./install.sh" :mod :sniprun} + :neovim/nvim-lspconfig {:mod :lspconfig} + :norcalli/nvim-colorizer.lua {:mod :colorizer} + :nvim-orgmode/orgmode {:mod :orgmode} + :nvim-telescope/telescope.nvim {:requires [[:nvim-lua/popup.nvim] + [:nvim-lua/plenary.nvim]] + :mod :telescope} + :nvim-treesitter/nvim-treesitter {:run ":TSUpdate" + :mod :treesitter} + :nvim-treesitter/playground {} + :p00f/nvim-ts-rainbow {} + :radenling/vim-dispatch-neovim {} + :rafamadriz/friendly-snippets {} + :skywind3000/asyncrun.vim {} + :tpope/vim-classpath {} + :tpope/vim-dadbod {} + :tpope/vim-dispatch {} + :tpope/vim-fugitive {:mod :fugitive} + :tpope/vim-git {} + :tpope/vim-pathogen {} + :tpope/vim-rails {} + :tpope/vim-repeat {} + :tpope/vim-surround {} + :tpope/vim-unimpaired {} + :tpope/vim-vinegar {} + :wbthomason/packer.nvim {:mod :packer} + :williamboman/nvim-lsp-installer {} + ; NeoVim lsp server installs + ; :luochen1990/rainbow {} + ; :thecontinium/asyncomplete-conjure.vim {} + } ; :tpope/vim-fireplace {} ; Clojure + ; :tpope/vim-sexp-mappings-for-regular-people {} + ) (use packages) - ;; call minpac#add('dense-analysis/ale') " Linting ;; call minpac#add('editorconfig/editorconfig-vim') ;; call minpac#add('elixir-lang/vim-elixir') " Elixir