From 3e7075f8944ac56b78c82f68835722807ad62e18 Mon Sep 17 00:00:00 2001 From: Chloe Kudryavtsev Date: Wed, 18 Jan 2023 10:11:34 +0100 Subject: nvim: update config (checkpoint) --- dot_config/nvim/init.lua | 1 + dot_config/nvim/lua/bindings.lua | 12 +++++++ dot_config/nvim/lua/plugins.lua | 26 +++++++++++--- dot_config/nvim/lua/plugins/conjure.lua | 13 +++++++ dot_config/nvim/lua/plugins/mini.lua | 1 + dot_config/nvim/lua/plugins/nvim-cmp.lua | 47 ++++++++++++++++++++++++++ dot_config/nvim/lua/plugins/nvim-lspconfig.lua | 28 +++++++++++---- 7 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 dot_config/nvim/lua/plugins/nvim-cmp.lua (limited to 'dot_config') diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index c60bdf2..e9871d7 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -7,6 +7,7 @@ require 'plugins' local options = { timeoutlen = 300, clipboard = 'unnamedplus', + completeopt = 'menu,menuone,noselect', mouse = 'a', smartcase = true, smartindent = true, diff --git a/dot_config/nvim/lua/bindings.lua b/dot_config/nvim/lua/bindings.lua index eb579f9..42c5896 100644 --- a/dot_config/nvim/lua/bindings.lua +++ b/dot_config/nvim/lua/bindings.lua @@ -1,3 +1,5 @@ +---@diagnostic disable:undefined-global + local util = require 'util' local env = vim.env @@ -11,11 +13,21 @@ if not util.hp 'which-key.nvim' then else -- general bindings that aren't specific to a plugin require 'which-key'.register { + -- diagnostics + [''] = { + e = { vim.diagnostic.open_float, 'diag float' }, + q = { vim.diagnostic.setloclist, 'diag locations' }, + }, + ['[d'] = { vim.diagnostic.goto_prev, 'prev diag' }, + [']d'] = { vim.diagnostic.goto_next, 'next diag' }, + + -- source ['s'] = { name = '+source', v = { function() dofile(env.MYVIMRC) end, 'Vimrc' }, ['%'] = { 'source %', 'Current File' }, }, + -- document missing builtins ['g'] = { t = 'Next tab', diff --git a/dot_config/nvim/lua/plugins.lua b/dot_config/nvim/lua/plugins.lua index 8bda6fd..f0bd53c 100644 --- a/dot_config/nvim/lua/plugins.lua +++ b/dot_config/nvim/lua/plugins.lua @@ -14,8 +14,8 @@ end local sust = {} colors = { default = 'default', -- in case of no packer - scheme = 'tokyonight', -- in case of yes packer - lualine = 'tokyonight', -- per plugin stuff from here on + scheme = 'onedark', -- in case of yes packer + lualine = 'onedark', -- per plugin stuff from here on } packer.startup({function(iuse) local tf = require 'transformer' @@ -32,6 +32,7 @@ packer.startup({function(iuse) -- colors use 'folke/tokyonight.nvim' + use 'olimorris/onedarkpro.nvim' -- editor use { run = function() @@ -40,6 +41,9 @@ packer.startup({function(iuse) { config = function() require 'nvim-treesitter.configs'.setup { ensure_installed = 'all', sync_install = true, + highlight = { + enable = true, + }, } end } 'nvim-treesitter/nvim-treesitter' sus 'neovim/nvim-lspconfig' @@ -47,19 +51,33 @@ packer.startup({function(iuse) sus 'linty-org/readline.nvim' sus 'nvim-lualine/lualine.nvim' - kbd 'kyazdani42/nvim-tree.lua' use 'folke/which-key.nvim' + -- completion, signatures, and snippets + sus 'hrsh7th/nvim-cmp' + use 'hrsh7th/cmp-nvim-lsp' + use 'PaterJason/cmp-conjure' + + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/cmp-cmdline' + use 'hrsh7th/cmp-path' + + use 'dcampos/nvim-snippy' + use 'dcampos/cmp-snippy' + + use 'ray-x/lsp_signature.nvim' + -- interactive features use { run = 'make' } 'nvim-telescope/telescope-fzf-native.nvim' kbd { requires = 'nvim-lua/plenary.nvim' } 'nvim-telescope/telescope.nvim' + kbd 'kyazdani42/nvim-tree.lua' kbd 'ggandor/leap.nvim' kbd 'Olical/conjure' -- language features use { ft = 'janet' } 'janet-lang/janet.vim' - use { ft = {'scm', 'janet', 'clojure' } } + use { ft = {'scm', 'janet', 'clojure', 'fennel' } } 'gpanders/nvim-parinfer' end, config = { compile_path = compiled, diff --git a/dot_config/nvim/lua/plugins/conjure.lua b/dot_config/nvim/lua/plugins/conjure.lua index f74e862..0062b12 100644 --- a/dot_config/nvim/lua/plugins/conjure.lua +++ b/dot_config/nvim/lua/plugins/conjure.lua @@ -1,6 +1,19 @@ +---@diagnostic disable:undefined-global local prefix = 'e' vim.g['conjure#mapping#prefix'] = prefix vim.g['conjure#extract#tree_sitter#enabled'] = true +-- disabling: lua, python, rust +vim.g['conjure#filetypes'] = { + 'clojure', + 'fennel', + 'hy', + 'janet', + 'julia', + 'lisp', + 'racket', + 'scheme', +} +vim.g['conjure#filetype#fennel'] = 'conjure.client.fennel.stdio' -- TODO: only do this in affected buffers -- how? diff --git a/dot_config/nvim/lua/plugins/mini.lua b/dot_config/nvim/lua/plugins/mini.lua index ebf75f3..7b2578c 100644 --- a/dot_config/nvim/lua/plugins/mini.lua +++ b/dot_config/nvim/lua/plugins/mini.lua @@ -1 +1,2 @@ require 'mini.comment'.setup{} +require 'mini.move'.setup{} diff --git a/dot_config/nvim/lua/plugins/nvim-cmp.lua b/dot_config/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..197d830 --- /dev/null +++ b/dot_config/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,47 @@ +---@diagnostic disable:undefined-global + +local cmp = require 'cmp' +local snp = require 'snippy' + +local mappings = require('snippy.mapping') +vim.keymap.set('i', '', mappings.expand_or_advance(''), + { desc = 'snippy next' }) +vim.keymap.set('s', '', mappings.next(''), + { desc = 'snippy next' }) +vim.keymap.set({ 'i', 's' }, '', mappings.previous(''), + { desc = 'snippy prev' }) +vim.keymap.set('x', '', mappings.cut_text, + { remap = true, desc = 'snippy cut' }) +vim.keymap.set('n', 'g', mappings.cut_text, + { remap = true, desc = 'snippy cut' }) + +cmp.setup { + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm { select = true }, + }, + snippet = { + expand = function(args) + snp.expand_snippet(args.body) + end, + }, + window = { + }, + sources = cmp.config.sources { + { name = 'nvim_lsp' }, + -- { name = 'conjure' }, + { name = 'snippy' }, + }, +} + +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' }, + }, { + { name = 'cmdline' }, + }) +}) diff --git a/dot_config/nvim/lua/plugins/nvim-lspconfig.lua b/dot_config/nvim/lua/plugins/nvim-lspconfig.lua index f8fae9f..07d9988 100644 --- a/dot_config/nvim/lua/plugins/nvim-lspconfig.lua +++ b/dot_config/nvim/lua/plugins/nvim-lspconfig.lua @@ -8,13 +8,27 @@ local function plist(...) return function(f) return p(f) end end +-- completion +local cap = require 'cmp_nvim_lsp'.default_capabilities() + -- mappings local wk = require 'which-key' + +-- signature help +local sg = require 'lsp_signature' +local sgconf = { + zindex = 50, + hint_enable = false, + extra_trigger_chars = {' '}, + toggle_key = '', +} + ---@diagnostic disable-next-line: unused-local local on_attach = function(c, b) local lsp = vim.lsp local lbf = lsp.buf vim.api.nvim_buf_set_option(b, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + sg.on_attach(sgconf, b) wk.register({ name = '+lsp', D = {lbf.declaration, 'goto declaration'}, @@ -48,11 +62,13 @@ local on_attach = function(c, b) end -- configs -local common = { on_attach = on_attach } -local deno = vim.deepcopy(common) -local tss = vim.deepcopy(common) -deno.root_dir = plist('deno.json', 'deno.jsonc') -tss.root_dir = plist('tsconfig.json', 'package.json') +local common = { on_attach = on_attach, capabilities = cap } +local clojure = vim.deepcopy(common) +local deno = vim.deepcopy(common) +local tss = vim.deepcopy(common) +clojure.root_dir = plist('project.clj', 'deps.edn', 'bb.edn', 'build.boot', 'shadow-cljs.edn', '.git') +deno.root_dir = plist('deno.json', 'deno.jsonc') +tss.root_dir = plist('tsconfig.json', 'package.json') -- servers local function enable(name, opts) @@ -64,7 +80,7 @@ local function enable(name, opts) end end -enable 'clojure_lsp' +enable('clojure_lsp', clojure) enable('denols', deno) enable 'gopls' enable 'ltex' -- cgit v1.2.3