From 62393d4dce5e62376854f529e0c5812dcdbb1852 Mon Sep 17 00:00:00 2001 From: Konstantin Bukley Date: Wed, 12 Jul 2023 16:32:40 +0300 Subject: [PATCH] nvim: update --- vim/.config/nvim/init.lua | 3 +- vim/.config/nvim/lua/mappings.lua | 8 +- vim/.config/nvim/lua/plugins/init.lua | 20 ++- vim/.config/nvim/lua/plugins/lsp.lua | 135 ++++---------------- vim/.config/nvim/lua/plugins/telescope.lua | 1 + vim/.config/nvim/lua/settings.lua | 3 +- vim/.config/nvim/plugin/packer_compiled.lua | 55 +++++--- 7 files changed, 85 insertions(+), 140 deletions(-) diff --git a/vim/.config/nvim/init.lua b/vim/.config/nvim/init.lua index edc41d4..c783985 100644 --- a/vim/.config/nvim/init.lua +++ b/vim/.config/nvim/init.lua @@ -2,7 +2,8 @@ -- License: WTFPL -- Description: Personal neovim configuration --- require('impatient') -- Should be at the top +vim.loader.enable() + require('filetypes') require('builtins') require('plugins') diff --git a/vim/.config/nvim/lua/mappings.lua b/vim/.config/nvim/lua/mappings.lua index 530afe1..cbf0f59 100644 --- a/vim/.config/nvim/lua/mappings.lua +++ b/vim/.config/nvim/lua/mappings.lua @@ -54,8 +54,6 @@ map('x', 'ga', ':EasyAlign') -- TODO: this should allow for gaip, but does n map('v', 'ga', ':EasyAlign') -- nvim-tree.lua --- nmap('n', ':NERDTreeToggle') --- nmap('N', ':NERDTreeFind') nmap('n', ':NvimTreeToggle') nmap('N', ':NvimTreeFindFile') @@ -79,3 +77,9 @@ nmap('', 'CtrlSFPrompt') -- trim whitespace nmap('W', ':TrimWhitespace') + + +-- EXPERIMENTAL: +-- nmap('x', ':!rm %') +nmap('x', ":call delete(expand('%')) | bdelete!") +nmap('q', ':copen') diff --git a/vim/.config/nvim/lua/plugins/init.lua b/vim/.config/nvim/lua/plugins/init.lua index 8a4583c..d034df7 100644 --- a/vim/.config/nvim/lua/plugins/init.lua +++ b/vim/.config/nvim/lua/plugins/init.lua @@ -1,5 +1,7 @@ local cmd, fn, opt, g = vim.cmd, vim.fn, vim.opt, vim.g +vim.loader.enable() + cmd [[packadd packer.nvim]] local packer = require('packer') local use = packer.use @@ -15,9 +17,6 @@ local use = packer.use packer.startup(function() use { 'wbthomason/packer.nvim', opt = true } - use 'lewis6991/impatient.nvim' - use 'nvim-lua/plenary.nvim' - use { 'shaunsingh/nord.nvim', config = function() @@ -50,11 +49,12 @@ packer.startup(function() use { 'nvim-tree/nvim-tree.lua', config = function() require('plugins/nvim-tree').config() - end + end, + opt = true, + cmd = { 'NvimTreeToggle', 'NvimTreeFindFile' } } use 'numtostr/comment.nvim' - use 'ellisonleao/glow.nvim' use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = fn.executable "make" == 1 } use { 'nvim-telescope/telescope.nvim', @@ -69,7 +69,11 @@ packer.startup(function() } -- Vimscript - use 'junegunn/vim-easy-align' + use { 'junegunn/vim-easy-align', + opt = true, + cmd = { 'EasyAlign' } + } + use 'christoomey/vim-tmux-navigator' use 'lewis6991/gitsigns.nvim' @@ -89,9 +93,11 @@ packer.startup(function() use 'andrewradev/splitjoin.vim' + use 'ggandor/leap.nvim' + use { 'VonHeikemen/lsp-zero.nvim', - branch = 'v1.x', + branch = 'v2.x', requires = { -- LSP Support {'neovim/nvim-lspconfig'}, -- Required diff --git a/vim/.config/nvim/lua/plugins/lsp.lua b/vim/.config/nvim/lua/plugins/lsp.lua index 57083e2..c63bb0b 100644 --- a/vim/.config/nvim/lua/plugins/lsp.lua +++ b/vim/.config/nvim/lua/plugins/lsp.lua @@ -1,120 +1,29 @@ --- local M = {} --- --- function M.config() --- local lspconfig = require('lspconfig') --- --- lspconfig.ansiblels.setup({}) --- lspconfig.bashls.setup({}) --- lspconfig.dockerls.setup({}) --- lspconfig.gopls.setup({}) --- lspconfig.jsonls.setup({}) --- lspconfig.solargraph.setup({}) --- --- -- local capabilities = require('cmp_nvim_lsp').default_capabilities() --- -- require('lspconfig')['solargraph'].setup({ capabilities = capabilities }) --- --- lspconfig.marksman.setup({}) --- lspconfig.terraformls.setup({}) --- lspconfig.vimls.setup({}) --- lspconfig.pylsp.setup({}) --- lspconfig.yamlls.setup({ --- settings = { --- yaml = { --- format = { --- enable = true, --- singleQuote = true --- } --- } --- } --- }) --- --- require("mason").setup({}) --- require("mason-lspconfig").setup() --- require("mason-tool-installer").setup({ --- -- https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md --- ensure_installed = { "bash-language-server", "black", "dockerfile-language-server", --- "isort", "json-lsp", "jsonlint", "lua-language-server", "marksman", "prettierd", --- "python-lsp-server", "rubocop", "shfmt", "solargraph", "terraform-ls", --- "vim-language-server", "yaml-language-server", --- }, --- auto_update = true, --- run_on_start = true --- }) --- --- -- Provide settings that should only apply to the "sumneko_lua" server --- local lua_runtime_path = vim.split(package.path, ';') --- table.insert(lua_runtime_path, "lua/?.lua") --- table.insert(lua_runtime_path, "lua/?/init.lua") --- table.insert(lua_runtime_path, vim.fn.stdpath('config') .. "lua/?.lua") --- --- lspconfig.sumneko_lua.setup({ --- settings = { --- Lua = { --- runtime = { --- -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) --- version = 'LuaJIT', --- -- Setup your lua path --- path = lua_runtime_path, --- }, --- format = { --- enable = true, --- defaultConfig = { --- keep_one_space_between_table_and_bracket = "false", --- } --- }, --- diagnostics = { --- -- Get the language server to recognize the `vim` global --- globals = {'vim'}, --- ["codestyle-check"] = "Any", --- }, --- -- Do not send telemetry data containing a randomized but unique identifier --- telemetry = { --- enable = false, --- }, --- }, --- } --- }) --- end +local lsp = require('lsp-zero').preset({}) - - --- local lsp = require('lsp-zero') - --- lsp.preset('recommended') --- lsp.set_preferences({ --- suggest_lsp_servers = true, --- setup_servers_on_start = true, --- set_lsp_keymaps = true, --- configure_diagnostics = true, --- cmp_capabilities = true, --- manage_nvim_cmp = true, --- call_servers = 'local', --- sign_icons = { --- error = 'E', --- warn = 'W', --- hint = 'H', --- info = 'I' --- } --- }) - -local lsp = require('lsp-zero').preset({ - name = 'minimal', - set_lsp_keymaps = true, - manage_nvim_cmp = true, - suggest_lsp_servers = false, -}) +lsp.on_attach(function(_, bufnr) + lsp.default_keymaps({buffer = bufnr}) +end) -- (Optional) Configure lua language server for neovim --- lsp.nvim_workspace() +require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls()) lsp.setup() +local cmp = require('cmp') +local cmp_action = require('lsp-zero').cmp_action() --- should be after setup -vim.diagnostic.config({ - virtual_text = true, - signs = true, - update_in_insert = false, - underline = true, - severity_sort = false, - float = true, +require('luasnip.loaders.from_vscode').lazy_load() + +cmp.setup({ + sources = { + {name = 'path'}, + {name = 'nvim_lsp'}, + {name = 'buffer', keyword_length = 3}, + {name = 'luasnip', keyword_length = 2}, + }, + mapping = { + -- `Enter` key to confirm completion + [''] = cmp.mapping.confirm({select = false}), + [''] = cmp_action.luasnip_supertab(), + [''] = cmp_action.luasnip_shift_supertab(), + } }) diff --git a/vim/.config/nvim/lua/plugins/telescope.lua b/vim/.config/nvim/lua/plugins/telescope.lua index 698bb70..ded14ad 100644 --- a/vim/.config/nvim/lua/plugins/telescope.lua +++ b/vim/.config/nvim/lua/plugins/telescope.lua @@ -2,6 +2,7 @@ local M = {} function M.setup() vim.keymap.set('n', 'ff', function() require('telescope.builtin').find_files({ hidden = true }) end) + vim.keymap.set('n', 'fo', function() require('telescope.builtin').find_files({ cwd = '~/Syncthing/Obsidian/Personal/', search_file = '*.md' }) end) vim.keymap.set('n', 'fh', function() require('telescope.builtin').help_tags() end) -- require('telescope.builtin').find_files({ hidden = true }) end diff --git a/vim/.config/nvim/lua/settings.lua b/vim/.config/nvim/lua/settings.lua index ea020ff..2f761aa 100644 --- a/vim/.config/nvim/lua/settings.lua +++ b/vim/.config/nvim/lua/settings.lua @@ -63,7 +63,8 @@ opt.list = true -- List mode opt.listchars = { trail = 'ยท', tab = '->' } opt.timeoutlen = 1000 -- Delay for mappings opt.ttimeoutlen = 0 -- Delay between modes -opt.shellcmdflag = '-ilc' -- Enables aliases from .bashrc in :! commands +-- TODO: leads to "bash: no job control in this shell" +-- opt.shellcmdflag = '-ilc' -- Enables aliases from .bashrc in :! commands opt.termguicolors = true -- 24-bit RGB color diff --git a/vim/.config/nvim/plugin/packer_compiled.lua b/vim/.config/nvim/plugin/packer_compiled.lua index 4299845..3874155 100644 --- a/vim/.config/nvim/plugin/packer_compiled.lua +++ b/vim/.config/nvim/plugin/packer_compiled.lua @@ -129,15 +129,10 @@ _G.packer_plugins = { path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", url = "https://github.com/lewis6991/gitsigns.nvim" }, - ["glow.nvim"] = { + ["leap.nvim"] = { loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/glow.nvim", - url = "https://github.com/ellisonleao/glow.nvim" - }, - ["impatient.nvim"] = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/impatient.nvim", - url = "https://github.com/lewis6991/impatient.nvim" + path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/leap.nvim", + url = "https://github.com/ggandor/leap.nvim" }, ["lsp-zero.nvim"] = { loaded = true, @@ -179,8 +174,12 @@ _G.packer_plugins = { url = "https://github.com/neovim/nvim-lspconfig" }, ["nvim-tree.lua"] = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", + commands = { "NvimTreeToggle", "NvimTreeFindFile" }, + config = { "\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\22plugins/nvim-tree\frequire\0" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-tree.lua", url = "https://github.com/nvim-tree/nvim-tree.lua" }, ["nvim-treesitter"] = { @@ -242,8 +241,11 @@ _G.packer_plugins = { url = "https://github.com/nvim-telescope/telescope.nvim" }, ["vim-easy-align"] = { - loaded = true, - path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-easy-align", + commands = { "EasyAlign" }, + loaded = false, + needs_bufread = false, + only_cond = false, + path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/vim-easy-align", url = "https://github.com/junegunn/vim-easy-align" }, ["vim-fugitive"] = { @@ -347,6 +349,20 @@ time([[Conditional loading of telescope-fzf-native.nvim]], false) -- Command lazy-loads time([[Defining lazy-load commands]], true) +pcall(vim.api.nvim_create_user_command, 'TSPlaygroundToggle', function(cmdargs) + require('packer.load')({'playground'}, { cmd = 'TSPlaygroundToggle', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins) + end, + {nargs = '*', range = true, bang = true, complete = function() + require('packer.load')({'playground'}, {}, _G.packer_plugins) + return vim.fn.getcompletion('TSPlaygroundToggle ', 'cmdline') + end}) +pcall(vim.api.nvim_create_user_command, 'EasyAlign', function(cmdargs) + require('packer.load')({'vim-easy-align'}, { cmd = 'EasyAlign', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins) + end, + {nargs = '*', range = true, bang = true, complete = function() + require('packer.load')({'vim-easy-align'}, {}, _G.packer_plugins) + return vim.fn.getcompletion('EasyAlign ', 'cmdline') + end}) pcall(vim.api.nvim_create_user_command, 'StartupTime', function(cmdargs) require('packer.load')({'vim-startuptime'}, { cmd = 'StartupTime', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins) end, @@ -354,12 +370,19 @@ pcall(vim.api.nvim_create_user_command, 'StartupTime', function(cmdargs) require('packer.load')({'vim-startuptime'}, {}, _G.packer_plugins) return vim.fn.getcompletion('StartupTime ', 'cmdline') end}) -pcall(vim.api.nvim_create_user_command, 'TSPlaygroundToggle', function(cmdargs) - require('packer.load')({'playground'}, { cmd = 'TSPlaygroundToggle', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins) +pcall(vim.api.nvim_create_user_command, 'NvimTreeToggle', function(cmdargs) + require('packer.load')({'nvim-tree.lua'}, { cmd = 'NvimTreeToggle', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins) end, {nargs = '*', range = true, bang = true, complete = function() - require('packer.load')({'playground'}, {}, _G.packer_plugins) - return vim.fn.getcompletion('TSPlaygroundToggle ', 'cmdline') + require('packer.load')({'nvim-tree.lua'}, {}, _G.packer_plugins) + return vim.fn.getcompletion('NvimTreeToggle ', 'cmdline') + end}) +pcall(vim.api.nvim_create_user_command, 'NvimTreeFindFile', function(cmdargs) + require('packer.load')({'nvim-tree.lua'}, { cmd = 'NvimTreeFindFile', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins) + end, + {nargs = '*', range = true, bang = true, complete = function() + require('packer.load')({'nvim-tree.lua'}, {}, _G.packer_plugins) + return vim.fn.getcompletion('NvimTreeFindFile ', 'cmdline') end}) time([[Defining lazy-load commands]], false)