diff --git a/nvim/.config/nvim/fnl/my_nvim/core.fnl b/nvim/.config/nvim/fnl/dotfiles/core.fnl similarity index 82% rename from nvim/.config/nvim/fnl/my_nvim/core.fnl rename to nvim/.config/nvim/fnl/dotfiles/core.fnl index 124e659..fda10db 100644 --- a/nvim/.config/nvim/fnl/my_nvim/core.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/core.fnl @@ -1,4 +1,4 @@ -(module my_vim.core +(module dotfiles.core {autoload {a aniseed.core} require @@ -18,8 +18,8 @@ (a.map safe-source ["~/.vimrc" "~/.vimrc.local"]) -(def- backup-dir "$HOME/.vim/backup") -(def- undo-dir "$HOME.vim/undo") +(def- backup-dir (.. (nvim.fn.glob "$HOME") "/.vim/backup")) +(def- undo-dir (.. (nvim.fn.glob "$HOME") "/.vim/backup")) (def- on-opts [ :autoindent @@ -47,7 +47,7 @@ (def- val-based-opts { - :t_Co 256 + ; :t_Co 256 :laststatus 2 :encoding "utf-8" :history 500 @@ -67,15 +67,16 @@ :undoreload 10000 :foldmethod "expr" :foldexpr "nvim_treesitter#foldexpr()" - :foldlevelstart 99 + :foldlevelstart 100 :foldlevel 99 :tabstop 2 :shiftwidth 2 :softtabstop 2 - :list "listchars=tab:➥\\ ,trail:·" + :list true + :listchars "tab:➥\\ ,trail:·" :backspace "indent,eol,start" ;allow backspacing over everything in insert mode :wildmode "list:longest,list:full" - :wrap "off" + :wrap false }) (defn- set-opt @@ -88,9 +89,13 @@ (a.map set-opt-on on-opts) -(a.map set-opt val-based-opts) +(a.map-indexed set-opt val-based-opts) (nvim.ex.syntax "on") -(nvim.ex.colorscheme "solarized8") +(nvim.ex.colorscheme :solarized8) -(nvim.fn.glob "~/.vimrc.local") + + +; (nvim.ex.autocmd "vimenter" "*" "++nested" "colorscheme" "solarized8") +; +; (nvim.fn.glob "~/.vimrc.local") diff --git a/nvim/.config/nvim/fnl/dotfiles/init.fnl b/nvim/.config/nvim/fnl/dotfiles/init.fnl new file mode 100644 index 0000000..d82beef --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/init.fnl @@ -0,0 +1,13 @@ +(module dotfiles.init + {autoload + {a aniseed.core} + require + {nvim aniseed.nvim}}) + + +(require :dotfiles.plugins) +(require :dotfiles.core) +(require :dotfiles.mapping) + +;(nvim.ex.source "~/.vimrc") + diff --git a/nvim/.config/nvim/fnl/my_nvim/mapping.fnl b/nvim/.config/nvim/fnl/dotfiles/mapping.fnl similarity index 95% rename from nvim/.config/nvim/fnl/my_nvim/mapping.fnl rename to nvim/.config/nvim/fnl/dotfiles/mapping.fnl index 35a8915..e9655fe 100644 --- a/nvim/.config/nvim/fnl/my_nvim/mapping.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/mapping.fnl @@ -1,4 +1,4 @@ -(module my_nvim.mapping +(module dotfiles.mapping {autoload {nvim aniseed.nvim nu aniseed.nvim.util core aniseed.core}}) @@ -52,7 +52,7 @@ (noremap :n :gph ":GitGutterPrevHunk") (noremap :n :gsh ":GitGutterStageHunk") -(noremap :n :li "LspInfo") +; (noremap :n :li "LspInfo") ;vim.api.nvim_set_keymap('n', 'li', 'LspInfo', { noremap=true, silent=true }) ; Open file in Marked 2 (markdown viewer) diff --git a/nvim/.config/nvim/fnl/dotfiles/plugin/conjure.fnl b/nvim/.config/nvim/fnl/dotfiles/plugin/conjure.fnl new file mode 100644 index 0000000..4a478fc --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/plugin/conjure.fnl @@ -0,0 +1,19 @@ +(module dotfiles.plugin.conjure + {autoload {nvim aniseed.nvim}}) + +; (set nvim.g.conjure#eval#result_register "*") +; (set nvim.g.conjure#log#botright true) +; (set nvim.g.conjure#mapping#doc_word "gk") +(set nvim.g.conjure#extract#tree_sitter#enabled true) + +; (n + +; +; +; au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#conjure#get_source_options({ +; \ 'name': 'conjure', +; \ 'allowlist': ['clojure', 'fennel'], +; \ 'triggers': {'*': ['/']}, +; \ 'time': 20, +; \ 'completor': function('asyncomplete#sources#conjure#completor'), +; \ })) diff --git a/nvim/.config/nvim/fnl/dotfiles/plugin/lspconfig.fnl b/nvim/.config/nvim/fnl/dotfiles/plugin/lspconfig.fnl new file mode 100644 index 0000000..3b651a2 --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/plugin/lspconfig.fnl @@ -0,0 +1,171 @@ +(module dotfiles.plugin.lspconfig + {autoload + {a aniseed.core + u dotfiles.util + nvim aniseed.nvim + } + }) + +(defn bufmap [mode from to] + (u.noremap mode from to {:local? true})) + +(defn nbufmap [from to] + (bufmap :n from to)) + +(defn xbufmap [from to] + (bufmap :x from to)) + + +(defn define-sign [level sign] + (let [sign-level (.. "LspDiagnosticsSign" level)] + (nvim.fn.sign_define sign-level + {:texthl sign-level + :text sign + :numhl sign-level}))) + +(define-sign :Error "☢️") +(define-sign :Warning "⚠️") +(define-sign :Hint "🔎") +(define-sign :Information "ℹ️") + +; -- function LspExecuteCommand(cmd, ...) +; -- arguments = {vim.uri_from_bufnr(0), vim.api.nvim_win_get_cursor(0)[1] - 1, vim.api.nvim_win_get_cursor(0)[2] -1} +; -- for _,a in pairs({...}) do table.insert(arguments, a) end +; -- vim.lsp.buf.execute_command({command = cmd, arguments = arguments}) +; -- end + + +(def core-nmappings + { + :gd "lua vim.lsp.buf.definition()" + :gD "lua vim.lsp.buf.declaration()" + :gi "lua vim.lsp.buf.implementation()" + :gr "lua vim.lsp.buf.references()" + :K "lua vim.lsp.buf.hover()" + "[g" "lua vim.lsp.diagnostic.goto_prev()" + "g" "lua vim.lsp.diagnostic.goto_prev()" + :ca "lua vim.lsp.buf.codeaction()" + :sld "lua vim.lsp.diagnostic.show_line_diagnostics()" + :rn "lua vim.lsp.buf.rename()" + :fa "lua vim.lsp.buf.formattting_sync()" + }) + +(def client-nmappings + {:clojure + { +; -- buf_set_keymap('n', 'cn', "lua LspExecuteCommand('clean-ns')", opts) +; -- buf_set_keymap('n', 'ref', "lua LspExecuteCommand('extract-function', vim.api.nvim_eval(\"input('Function name: ')\"))", opts) +; -- buf_set_keymap('x', 'ref', "lua LspExecuteCommand('extract-function', vim.api.nvim_eval(\"input('Function name: ')\"))", opts) +; -- buf_set_keymap('n', 'id', "lua LspExecuteCommand('inline-symbol')", opts) +; -- buf_set_keymap('x', 'id', "lua LspExecuteCommand('inline-symbol')", opts) +; -- buf_set_keymap('n', 'il', "lua LspExecuteCommand('introduce-let', vim.api.nvim_eval(\"input('Binding name: ')\"))", opts) +; -- buf_set_keymap('x', 'il', "lua LspExecuteCommand('introduce-let', vim.api.nvim_eval(\"input('Binding name: ')\"))", opts) +; -- buf_set_keymap('n', 'm2l', "lua LspExecuteCommand('move-to-let', vim.api.nvim_eval(\"input('Binding name: ')\"))", opts) +; -- buf_set_keymap('x', 'm2l', "lua LspExecuteCommand('move-to-let', vim.api.nvim_eval(\"input('Binding name: ')\"))", opts) + } + }) + + +(defn bind-client-mappings [client] + (let [mappings (a.get client-nmappings client)] + (when mappings + (each [mapping cmd (pairs mappings)] + (nbufmap mapping cmd))))) + +(defn on_attach [client bufnr] + (each [mapping cmd (pairs core-nmappings)] + (nbufmap mapping cmd)) + + ; x mode mappings + (xbufmap :fa "lua vim.lsp.buf.formattting_sync()") + +; -- buf_set_keymap('n', 'gs', 'lua vim.lsp.buf.document_symbol()', opts) +; -- buf_set_keymap('n', 'gS', 'lua vim.lsp.buf.workspace_symbol()', opts) +; -- buf_set_keymap('n', 'gt', 'lua vim.lsp.buf.type_definition()', opts) +; -- buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) +; -- buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) +; -- buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) +; -- buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) +; -- buf_set_keymap('n', 'ic', "lua vim.lsp.buf.incoming_calls()", opts) +; -- buf_set_keymap('x', 'ic', "lua vim.lsp.buf.incoming_calls()", opts) + + + (bind-client-mappings client) +; -- vim.api.nvim_command[[autocmd BufWritePre lua vim.lsp.buf.formatting_sync()]] +; -- 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(0), 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 :lspinstall)] + (when lspi + (defn setup-servers [] + (lspi.setup) + (let [lspconfig (require :lspconfig) + servers (lspi.installed_servers)] + (each [_ server (pairs servers)] + ((. lspconfig server :setup) {:on_attach on_attach :flags {:debounce_text_changes 150} })))) + + (setup-servers) + + (u.nnoremap :li "LspInfo"))) + +; ()lspi.post_install_hook = post_lsp_install +; -- require'lspinstall'.post_install_hook = function () +; -- setup_servers() -- reload installed servers +; -- vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server +; -- end + +; -- local nvim_lsp = require('lspconfig') +; -- +; -- function LspExecuteCommand(cmd, ...) +; -- arguments = {vim.uri_from_bufnr(0), vim.api.nvim_win_get_cursor(0)[1] - 1, vim.api.nvim_win_get_cursor(0)[2] -1} +; -- for _,a in pairs({...}) do table.insert(arguments, a) end +; -- vim.lsp.buf.execute_command({command = cmd, arguments = arguments}) +; -- end +; -- +; -- -- Use an on_attach function to only map the following keys +; -- -- after the language server attaches to the current buffer +; -- local on_attach = function(client, bufnr) +; -- local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end +; -- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end +; -- +; -- --Enable completion triggered by +; -- buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') +; -- +; -- -- Mappings. +; -- local opts = { noremap=true, silent=true } +; -- +; -- -- See `:help vim.lsp.*` for documentation on any of the below functions + +; -- +; -- +; -- -- 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(0), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]] +; -- +; -- vim.api.nvim_command[[lua print("Lsp Client Attached.")]] +; -- end +; -- +; -- +; -- -- vim.api.nvim_set_keymap('n', 'li', 'LspInfo', { noremap=true, silent=true }) +; -- +; -- +; -- local function setup_servers() +; -- require'lspinstall'.setup() +; -- local servers = require'lspinstall'.installed_servers() +; -- for _, server in pairs(servers) do +; -- require'lspconfig'[server].setup{ +; -- on_attach = on_attach, +; -- flags = { +; -- debounce_text_changes = 150, +; -- } +; -- } +; -- end +; -- end +; -- +; -- setup_servers() +; -- +; -- -- Automatically reload after `:LspInstall ` so we don't have to restart neovim +; -- require'lspinstall'.post_install_hook = function () +; -- setup_servers() -- reload installed servers +; -- vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server +; -- end diff --git a/nvim/.config/nvim/fnl/dotfiles/plugin/packer.fnl b/nvim/.config/nvim/fnl/dotfiles/plugin/packer.fnl new file mode 100644 index 0000000..1f1efb4 --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/plugin/packer.fnl @@ -0,0 +1,9 @@ +(module dotfiles.plugin.packer + {autoload + {u dotfiles.util} + require + {nvim aniseed.nvim}}) + +(u.nnoremap :pi :PackerInstall) +(u.nnoremap :pu :PackerUpdate) + diff --git a/nvim/.config/nvim/fnl/dotfiles/plugin/telescope.fnl b/nvim/.config/nvim/fnl/dotfiles/plugin/telescope.fnl new file mode 100644 index 0000000..6610fa5 --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/plugin/telescope.fnl @@ -0,0 +1,32 @@ +(module dotfiles.plugin.telescope + {autoload {nvim aniseed.nvim + util dotfiles.util + telescope telescope}}) + +(telescope.setup + {:defaults + {:vimgrep_arguments ["ag" "--nocolor=never" "--noheading" + "--files-with-matches" "--number" "--column" + "--smart-case" "--hidden" "--follow" + "-g" "!.git/"]}}) + + +(util.lnnoremap :ff "Telescope find_files hidden=true") +(util.lnnoremap :f- "Telescope file_browser") +(util.lnnoremap :fg "Telescope live_grep") +(util.lnnoremap :* "Telescope grep_string") +(util.lnnoremap :fb "Telescope buffers") +(util.lnnoremap :fH "Telescope help_tags") +(util.lnnoremap :fm "Telescope keymaps") +(util.lnnoremap :fM "Telescope marks") +(util.lnnoremap :fh "Telescope oldfiles") +(util.lnnoremap :ft "Telescope filetypes") +(util.lnnoremap :fc "Telescope commands") +(util.lnnoremap :fC "Telescope command_history") +(util.lnnoremap :fq "Telescope quickfix") +(util.lnnoremap :fl "Telescope loclist") +(util.lnnoremap :fsa "Telescope lsp_code_actions") +(util.lnnoremap :fsi "Telescope lsp_implementations") +(util.lnnoremap :fsr "Telescope lsp_references") +(util.lnnoremap :fsS "Telescope lsp_document_symbols") +(util.lnnoremap :fss "Telescope lsp_workspace_symbols") diff --git a/nvim/.config/nvim/fnl/dotfiles/plugin/treesitter.fnl b/nvim/.config/nvim/fnl/dotfiles/plugin/treesitter.fnl new file mode 100644 index 0000000..1fcb8df --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/plugin/treesitter.fnl @@ -0,0 +1,6 @@ +(module dotfiles.plugin.treesitter + {autoload {treesitter nvim-treesitter.configs}}) + +(treesitter.setup + {:highlight {:enable true + :additional_vim_regex_highlighting false}}) diff --git a/nvim/.config/nvim/fnl/dotfiles/plugins.fnl b/nvim/.config/nvim/fnl/dotfiles/plugins.fnl new file mode 100644 index 0000000..c15e8ed --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/plugins.fnl @@ -0,0 +1,116 @@ +(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))))) + +(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)) + )))) + + +(def- packages + { + :wbthomason/packer.nvim {:mod :packer} + :airblade/vim-gitgutter {} ; Git + :clojure-vim/vim-jack-in {} ; Conjure support - jack-in with nrepl dependencies + :thecontinium/asyncomplete-conjure.vim {} + :tpope/vim-dispatch {} ; Conjure support - jack-in with nrepl dependencies + :Olical/conjure {} ; Clojure + :Olical/aniseed {} + :Olical/fennel.vim {} ; Fennel + :neovim/nvim-lspconfig {:mod :lspconfig} ; NeoVim lsp config + :kabouzeid/nvim-lspinstall {} ; NeoVim lsp server installs + :airblade/vim-gitgutter {} ; Git +:kovisoft/paredit {} +:luochen1990/rainbow {} +:jiangmiao/auto-pairs {} ; backets, parens, and quotes in pairs +:nvim-treesitter/nvim-treesitter {:run ":TSUpdate" :mod :treesitter} +:hashivim/vim-terraform {} ; Terraform +:skywind3000/asyncrun.vim {} ; :AsyncRun +:tpope/vim-classpath {} +:tpope/vim-fugitive {} ; Git +:tpope/vim-git {} ; Git Commit Message +:tpope/vim-pathogen {} +:tpope/vim-surround {} +:tpope/vim-repeat {} +:tpope/vim-unimpaired {} +:tpope/vim-vinegar {} +:radenling/vim-dispatch-neovim {} ; Clojure + :nvim-telescope/telescope.nvim {:requires [[:nvim-lua/popup.nvim] [:nvim-lua/plenary.nvim]] :mod :telescope} + + } + +; :tpope/vim-fireplace {} ; Clojure +; :tpope/vim-sexp-mappings-for-regular-people {} + ) + +(use packages) + +;;(nu.fn-bridge +;; :DeleteHiddenBuffers +;; :dotfiles.mapping :delete-hidden-buffers) + +; " Define user commands for updating/cleaning the plugins. +; " Each of them loads minpac, reloads .vimrc to register the +; information of plugins, then performs the task. +; command! PackUpdate call PackInit() | call minpac#update('', {'do': 'call minpac#status()'}) +; command! PackClean call PackInit() | call minpac#clean() +; command! PackStatus packadd minpac | call minpac#status() + + +;; call minpac#add('dense-analysis/ale') " Linting +;; call minpac#add('editorconfig/editorconfig-vim') +;; call minpac#add('elixir-lang/vim-elixir') " Elixir +;; call minpac#add('ElmCast/elm-vim') " Elm +;; call minpac#add('jgdavey/tslime.vim', {'branch': 'main'}) " Send to Tmux +;; call minpac#add('leafgarland/typescript-vim') " TypeScript +;; call minpac#add('idris-hackers/idris-vim') " Idris +;; call minpac#add('mxw/vim-jsx') " React JSX support +;; call minpac#add('neomake/neomake') " Linting/Make +;; call minpac#add('nvie/vim-flake8') " Python +;; call minpac#add('pangloss/vim-javascript') " JavaScript +;; call minpac#add('prabirshrestha/async.vim') " Vim/NeoVim async normalization +;; call minpac#add('prabirshrestha/asyncomplete.vim') " Language Server Protocol +;; call minpac#add('raichoo/purescript-vim') " PureScript +;; call minpac#add('reasonml-editor/vim-reason') " ReasonML +;; call minpac#add('thoughtbot/vim-rspec') +;; call minpac#add('vim-erlang/erlang-motions.vim') " Erlang +;; call minpac#add('vim-erlang/vim-erlang-runtime') " Erlang +;; call minpac#add('vim-erlang/vim-erlang-compiler') " Erlang +;; call minpac#add('vim-erlang/vim-erlang-omnicomplete') " Erlang +;; call minpac#add('vim-erlang/vim-erlang-tags') " Erlang +;; call minpac#add('vim-erlang/vim-erlang-skeletons') " Erlang +;; call minpac#add('vim-ruby/vim-ruby') " Ruby +;; call minpac#add('vim-syntastic/syntastic') +;; call minpac#add('vim-jp/syntax-vim-ex') +;; call minpac#add('tsandall/vim-rego') " Rego +;; + +;; " call minpac#add('guns/vim-clojure-static') " Clojure +;; "" call minpac#add('guns/vim-sexp') " Lisps +;; " call minpac#add('ncm2/float-preview.nvim') " autocomplete with preview +;; " call minpac#add('Shougo/deoplete.nvim') " async completion +;; " call minpac#add('prabirshrestha/vim-lsp') " Language Server Protocol +;; " call minpac#add('rhysd/vim-lsp-ale') " vim-lsp + ALE +;; " call minpac#add('mattn/vim-lsp-settings') " Generic LSP Server install and settings for all languages +;; " call minpac#add('prabirshrestha/asyncomplete-lsp.vim') " Language Server Protocol +;; " call minpac#add('prabirshrestha/vim-lsp') " Language Server Protocol +;; " call minpac#add('rhysd/vim-lsp-ale') " vim-lsp + ALE diff --git a/nvim/.config/nvim/fnl/dotfiles/util.fnl b/nvim/.config/nvim/fnl/dotfiles/util.fnl new file mode 100644 index 0000000..54fb013 --- /dev/null +++ b/nvim/.config/nvim/fnl/dotfiles/util.fnl @@ -0,0 +1,21 @@ +(module dotfiles.util + {autoload + {a aniseed.core} + require + {nvim aniseed.nvim}}) + + +(defn noremap [mode from to opts] + (let [map-opts {:noremap true :silent true} + to (.. ":" to "") + buff-num (a.get opts :buff-num)] + + (if (or (a.get opts :local?) buff-num ) + (nvim.buf_set_keymap (or buff-num 0) mode from to map-opts) + (nvim.set_keymap mode from to map-opts)))) + +(defn nnoremap [from to opts] + (noremap :n from to opts)) + +(defn lnnoremap [from to] + (nnoremap (.. "" from) to)) diff --git a/nvim/.config/nvim/fnl/my_nvim/init.fnl b/nvim/.config/nvim/fnl/my_nvim/init.fnl deleted file mode 100644 index d04aa37..0000000 --- a/nvim/.config/nvim/fnl/my_nvim/init.fnl +++ /dev/null @@ -1,10 +0,0 @@ -(module my_vim.init - {autoload - {a aniseed.core} - require - {nvim aniseed.nvim}}) - -(nvim.ex.source "~/.vimrc") - -(require :my_nvim.core) -(require :my_nvim.mapping) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index c321d42..a21e4aa 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,111 +1,41 @@ --- Source init.vim for migration of vimrc to neovim -vim.fn.sign_define("LspDiagnosticsSignError", - {texthl = "LspDiagnosticsSignError", text = "☢️", numhl = "LspDiagnosticsSignError"}) -vim.fn.sign_define("LspDiagnosticsSignWarning", - {texthl = "LspDiagnosticsSignWarning", text = "⚠️", numhl = "LspDiagnosticsSignWarning"}) -vim.fn.sign_define("LspDiagnosticsSignHint", - {texthl = "LspDiagnosticsSignHint", text = "🔎", numhl = "LspDiagnosticsSignHint"}) -vim.fn.sign_define("LspDiagnosticsSignInformation", - {texthl = "LspDiagnosticsSignInformation", text = "ℹ️", numhl = "LspDiagnosticsSignInformation"}) +local execute = vim.api.nvim_command +local fn = vim.fn -local nvim_lsp = require('lspconfig') +local pack_path = fn.stdpath("data") .. "/site/pack" +local fmt = string.format -function LspExecuteCommand(cmd, ...) - arguments = {vim.uri_from_bufnr(0), vim.api.nvim_win_get_cursor(0)[1] - 1, vim.api.nvim_win_get_cursor(0)[2] -1} - for _,a in pairs({...}) do table.insert(arguments, a) end - vim.lsp.buf.execute_command({command = cmd, arguments = arguments}) -end - --- Use an on_attach function to only map the following keys --- after the language server attaches to the current buffer -local on_attach = function(client, bufnr) - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - - --Enable completion triggered by - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - local opts = { noremap=true, silent=true } - - -- See `:help vim.lsp.*` for documentation on any of the below functions - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'gs', 'lua vim.lsp.buf.document_symbol()', opts) - buf_set_keymap('n', 'gS', 'lua vim.lsp.buf.workspace_symbol()', opts) - buf_set_keymap('n', 'gt', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', '[g', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']g', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - buf_set_keymap('n', 'cn', "lua LspExecuteCommand('clean-ns')", opts) - buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', 'ref', "lua LspExecuteCommand('extract-function', vim.api.nvim_eval(\"input('Function name: ')\"))", opts) - buf_set_keymap('x', 'ref', "lua LspExecuteCommand('extract-function', vim.api.nvim_eval(\"input('Function name: ')\"))", opts) - buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) - buf_set_keymap('n', 'fa', "lua vim.lsp.buf.formatting_sync()", opts) - buf_set_keymap('x', 'fa', "lua vim.lsp.buf.formatting_sync()", opts) - buf_set_keymap('n', 'ic', "lua vim.lsp.buf.incoming_calls()", opts) - buf_set_keymap('x', 'ic', "lua vim.lsp.buf.incoming_calls()", opts) - buf_set_keymap('n', 'id', "lua LspExecuteCommand('inline-symbol')", opts) - buf_set_keymap('x', 'id', "lua LspExecuteCommand('inline-symbol')", opts) - buf_set_keymap('n', 'il', "lua LspExecuteCommand('introduce-let', vim.api.nvim_eval(\"input('Binding name: ')\"))", opts) - buf_set_keymap('x', 'il', "lua LspExecuteCommand('introduce-let', vim.api.nvim_eval(\"input('Binding name: ')\"))", opts) - buf_set_keymap('n', 'm2l', "lua LspExecuteCommand('move-to-let', vim.api.nvim_eval(\"input('Binding name: ')\"))", opts) - buf_set_keymap('x', 'm2l', "lua LspExecuteCommand('move-to-let', vim.api.nvim_eval(\"input('Binding name: ')\"))", opts) - - vim.api.nvim_command[[autocmd BufWritePre lua vim.lsp.buf.formatting_sync()]] - -- 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(0), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]] - - vim.api.nvim_command[[lua print("Lsp Client Attached.")]] -end - - --- vim.api.nvim_set_keymap('n', 'li', 'LspInfo', { noremap=true, silent=true }) - - -local function setup_servers() - require'lspinstall'.setup() - local servers = require'lspinstall'.installed_servers() - for _, server in pairs(servers) do - require'lspconfig'[server].setup{ - on_attach = on_attach, - flags = { - debounce_text_changes = 150, - } - } +function ensure (user, repo) + -- Ensures a given github.com/USER/REPO is cloned in the pack/packer/start directory. + local install_path = fmt("%s/packer/start/%s", pack_path, repo, repo) + if fn.empty(fn.glob(install_path)) > 0 then + execute(fmt("!git clone https://github.com/%s/%s %s", user, repo, install_path)) + execute(fmt("packadd %s", repo)) end end -setup_servers() +-- Bootstrap essential plugins required for installing and loading the rest. +ensure("wbthomason", "packer.nvim") +ensure("Olical", "aniseed") --- Automatically reload after `:LspInstall ` so we don't have to restart neovim -require'lspinstall'.post_install_hook = function () - setup_servers() -- reload installed servers - vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server -end +-- Enable Aniseed's automatic compilation and loading of Fennel source code. +vim.g["aniseed#env"] = { + module = "dotfiles.init", + compile = true +} - --- require'nvim-treesitter.configs'.setup { --- ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages --- -- ignore_install = { "javascript" }, -- List of parsers to ignore installing --- -- highlight = { --- -- enable = true, -- false will disable the whole extension --- -- disable = { "c", "rust" }, -- list of language that will be disabled --- -- -- Setting this to true will run `:h syntax` and tree-sitter at the same time. --- -- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). --- -- -- Using this option may slow down your editor, and you may see some duplicate highlights. --- -- -- Instead of true it can also be a list of languages --- -- additional_vim_regex_highlighting = false, --- -- }, --- } --- --- -vim.g["aniseed#env"] = { module = "my_nvim.init" } +-- -- require'nvim-treesitter.configs'.setup { +-- -- ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages +-- -- -- ignore_install = { "javascript" }, -- List of parsers to ignore installing +-- -- -- highlight = { +-- -- -- enable = true, -- false will disable the whole extension +-- -- -- disable = { "c", "rust" }, -- list of language that will be disabled +-- -- -- -- Setting this to true will run `:h syntax` and tree-sitter at the same time. +-- -- -- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). +-- -- -- -- Using this option may slow down your editor, and you may see some duplicate highlights. +-- -- -- -- Instead of true it can also be a list of languages +-- -- -- additional_vim_regex_highlighting = false, +-- -- -- }, +-- -- } +-- -- +-- -- +-- --