From c82203111af0bdb88cf77ae735bb51d7dcaee608 Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Sun, 30 Oct 2022 12:49:59 -0700 Subject: [PATCH] update nvim config --- nvim/init.vim | 8 +++-- nvim/keybindings.vim | 9 +++-- nvim/lua/plugins.lua | 63 ++++++++++++++++++++++++++------- nvim/lua/settings.lua | 1 + nvim/plugin-confs/lspconfig.lua | 3 +- nvim/plugin-confs/nvim-cmp.lua | 62 +++++++++++++++++++++++--------- nvim/plugin/packer_compiled.lua | 23 +++++++----- 7 files changed, 123 insertions(+), 46 deletions(-) diff --git a/nvim/init.vim b/nvim/init.vim index 25014be..623dee9 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -5,6 +5,9 @@ if has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif +autocmd FileType help wincmd L +autocmd FileType man wincmd L + let g:mapleader = "\" let g:maplocalleader = ',' set completeopt=menu,menuone,noselect @@ -35,7 +38,7 @@ source ~/.config/nvim/plugin-confs/null-ls.lua source ~/.config/nvim/plugin-confs/nvim-cmp.lua source ~/.config/nvim/plugin-confs/fidget.lua source ~/.config/nvim/plugin-confs/symbols-outline.lua -source ~/.config/nvim/plugin-confs/nvim-docs-view.lua +" source ~/.config/nvim/plugin-confs/nvim-docs-view.lua " nvim and vim plugins source ~/.vim/plugin-confs/floaterm.vim @@ -67,7 +70,8 @@ command! -bang -nargs=? -complete=dir Buffers \ call fzf#vim#buffers(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh']}), 0) command! Reload execute "source ~/.vimrc" -command! Config execute ":e ~/.vimrc" +command! Config execute ":e ~/.config/nvim/init.vim" +command! Plugins execute ":e ~/.config/nvim/lua/plugins.lua" command! Env execute ":Dotenv .env" command! MakeTags !ctags -R . command! Ovewrite execute ":w !sudo tee %" diff --git a/nvim/keybindings.vim b/nvim/keybindings.vim index 897c42e..9fa6c5b 100644 --- a/nvim/keybindings.vim +++ b/nvim/keybindings.vim @@ -18,7 +18,7 @@ nmap :bprev nmap :wa:FloatermToggle floatterm " open file under cursor, create if necessary -nnoremap // :Lines +nnoremap // :Telescope current_buffer_fuzzy_find nnoremap ?? :BLines nmap gA :lua vim.lsp.buf.code_actions() @@ -81,14 +81,13 @@ nmap isp :-1read $HOME/Templates/python.py4jw nmap j :AnyJump -nmap K :DocsViewToggle -" nmap K :lua vim.lsp.buf.hover() +" nmap K :DocsViewToggle +nmap K :lua vim.lsp.buf.hover() -nmap lD :Telescope lsp_definitions +nmap ld :Telescope lsp_definitions nmap la :lua vim.lsp.buf.code_action() nmap lci :Telescope lsp_incoming_calls nmap lco :Telescope lsp_outgoing_calls -nmap ld :Telescope lsp_declarations nmap lh :lua vim.lsp.buf.signature_help() nmap li :Telescope lsp_implementations nmap lr :Telescope lsp_references diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 1299f4c..099d246 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -39,17 +39,17 @@ return require('packer').startup(function(use) dismiss = "", }, }, - filetypes = { - yaml = false, - markdown = false, - help = false, - gitcommit = false, - gitrebase = false, - hgcommit = false, - svn = false, - cvs = false, - ["."] = false, - }, + -- filetypes = { + -- yaml = false, + -- markdown = false, + -- help = false, + -- gitcommit = false, + -- gitrebase = false, + -- hgcommit = false, + -- svn = false, + -- cvs = false, + -- ["."] = false, + -- }, copilot_node_command = 'node', -- Node version must be < 18 plugin_manager_path = vim.fn.stdpath("data") .. "/site/pack/packer", server_opts_overrides = {}, @@ -63,7 +63,7 @@ return require('packer').startup(function(use) after = { "copilot.lua" }, config = function () require("copilot_cmp").setup({ - -- method = "getCompletionsCycling", + method = "getCompletionsCycling", formatters = { insert_text = require("copilot_cmp.format").remove_existing } @@ -76,6 +76,43 @@ return require('packer').startup(function(use) run = function() vim.fn['fzf#install']() end } + use { + "lewis6991/hover.nvim", + config = function() + require("hover").setup { + init = function() + -- Require providers + require("hover.providers.lsp") + -- require('hover.providers.gh') + -- require('hover.providers.jira') + require('hover.providers.man') + require('hover.providers.dictionary') + end, + preview_opts = { + border = "rounded" + -- border = { + -- { "â•­", "FloatBorder" }, + -- { "─", "FloatBorder" }, + -- { "â•®", "FloatBorder" }, + -- { "│", "FloatBorder" }, + -- { "╯", "FloatBorder" }, + -- { "─", "FloatBorder" }, + -- { "â•°", "FloatBorder" }, + -- { "│", "FloatBorder" }, + -- } + }, + -- Whether the contents of a currently open hover window should be moved + -- to a :h preview-window when pressing the hover keymap. + preview_window = false, + title = true + } + + -- Setup keymaps + vim.keymap.set("n", "K", require("hover").hover, {desc = "hover.nvim"}) + vim.keymap.set("n", "gK", require("hover").hover_select, {desc = "hover.nvim (select)"}) + end + } + use 'ap/vim-css-color' use 'jiangmiao/auto-pairs' use 'junegunn/fzf.vim' @@ -96,7 +133,7 @@ return require('packer').startup(function(use) use 'ojroques/nvim-lspfuzzy' use 'L3MON4D3/LuaSnip' - use 'amrbashir/nvim-docs-view' + -- use 'amrbashir/nvim-docs-view' use 'hrsh7th/cmp-buffer' use 'hrsh7th/cmp-nvim-lsp' use 'hrsh7th/cmp-nvim-lua' diff --git a/nvim/lua/settings.lua b/nvim/lua/settings.lua index 6553a08..c814275 100644 --- a/nvim/lua/settings.lua +++ b/nvim/lua/settings.lua @@ -4,6 +4,7 @@ local A = vim.api g.mapleader = "" g.maplocalleader = ',' +o.showmode = false o.termguicolors = true o.background = 'dark' o.mouse = 'a' diff --git a/nvim/plugin-confs/lspconfig.lua b/nvim/plugin-confs/lspconfig.lua index 7f0e5b6..7f730ee 100644 --- a/nvim/plugin-confs/lspconfig.lua +++ b/nvim/plugin-confs/lspconfig.lua @@ -185,10 +185,11 @@ lsp_installer.on_server_ready(function(server) end) -local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'sumneko_lua', 'rust_analyzer', 'clangd', 'ansiblels' } +local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'rust_analyzer', 'clangd', 'ansiblels' } for _, lsp in pairs(servers) do require('lspconfig')[lsp].setup { on_attach = on_attach, + handlers = handlers, flags = { -- This will be the default in neovim 0.7+ debounce_text_changes = 150, diff --git a/nvim/plugin-confs/nvim-cmp.lua b/nvim/plugin-confs/nvim-cmp.lua index 95b88c5..21f17a0 100644 --- a/nvim/plugin-confs/nvim-cmp.lua +++ b/nvim/plugin-confs/nvim-cmp.lua @@ -8,6 +8,7 @@ capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) -- luasnip setup local luasnip = require 'luasnip' + local has_words_before = function() if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end local line, col = unpack(vim.api.nvim_win_get_cursor(0)) @@ -36,24 +37,53 @@ cmp.setup({ -- [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. -- }, mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 's' }), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, - select = false, + select = true, }, [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif has_words_before() then - cmp.complete() - else - fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. - end + if has_words_before() then + require('copilot.suggestion').accept() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif not has_words_before() then + cmp.complete() + else + fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. + end + -- if cmp.visible() then + -- cmp.select_next_item() + -- elseif has_words_before() then + -- cmp.complete() + -- else + -- fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. + -- end end, { "i", "s" }), [''] = cmp.mapping(function() if cmp.visible() then @@ -105,9 +135,9 @@ for _, lsp in ipairs(servers) do end -cmp.event:on("menu_opened", function() - vim.b.copilot_suggestion_hidden = true -end) -cmp.event:on("menu_closed", function() - vim.b.copilot_suggestion_hidden = false -end) +-- cmp.event:on("menu_opened", function() +-- vim.b.copilot_suggestion_hidden = true +-- end) +-- cmp.event:on("menu_closed", function() +-- vim.b.copilot_suggestion_hidden = false +-- end) diff --git a/nvim/plugin/packer_compiled.lua b/nvim/plugin/packer_compiled.lua index 2c40435..a31dc50 100644 --- a/nvim/plugin/packer_compiled.lua +++ b/nvim/plugin/packer_compiled.lua @@ -115,7 +115,7 @@ _G.packer_plugins = { url = "https://github.com/saadparwaiz1/cmp_luasnip" }, ["copilot-cmp"] = { - config = { "\27LJ\2\n9\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\nsetup\16copilot_cmp\frequire\0" }, + config = { "\27LJ\2\n¶\1\0\0\a\0\t\0\0146\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0005\3\6\0006\4\0\0'\6\4\0B\4\2\0029\4\5\4=\4\a\3=\3\b\2B\0\2\1K\0\1\0\15formatters\16insert_text\1\0\0\20remove_existing\23copilot_cmp.format\1\0\1\vmethod\26getCompletionsCycling\nsetup\16copilot_cmp\frequire\0" }, load_after = {}, loaded = true, needs_bufread = false, @@ -124,7 +124,7 @@ _G.packer_plugins = { }, ["copilot.lua"] = { after = { "copilot-cmp" }, - config = { "\27LJ\2\n‘\4\0\0\6\0\20\0\0276\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\6\0005\3\3\0005\4\4\0=\4\5\3=\3\a\0025\3\b\0005\4\t\0=\4\5\3=\3\n\0025\3\v\0=\3\f\0026\3\r\0009\3\14\0039\3\15\3'\5\16\0B\3\2\2'\4\17\0&\3\4\3=\3\18\0024\3\0\0=\3\19\2B\0\2\1K\0\1\0\26server_opts_overrides\24plugin_manager_path\22/site/pack/packer\tdata\fstdpath\afn\bvim\14filetypes\1\0\t\bsvn\1\rhgcommit\1\14gitrebase\1\14gitcommit\1\thelp\1\rmarkdown\1\tyaml\1\6.\1\bcvs\1\15suggestion\1\0\4\tnext\n\fdismiss\n\tprev\n\vaccept\n\1\0\3\rdebounce\3K\fenabled\2\17auto_trigger\2\npanel\1\0\1\25copilot_node_command\tnode\vkeymap\1\0\5\14jump_prev\a[[\frefresh\agr\vaccept\t\topen\v\14jump_next\a]]\1\0\2\17auto_refresh\1\fenabled\2\nsetup\fcopilot\frequire-\1\0\4\0\3\0\0066\0\0\0009\0\1\0003\2\2\0)\3d\0B\0\3\1K\0\1\0\0\rdefer_fn\bvim\0" }, + config = { "\27LJ\2\n¹\3\0\0\6\0\18\0\0256\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\6\0005\3\3\0005\4\4\0=\4\5\3=\3\a\0025\3\b\0005\4\t\0=\4\5\3=\3\n\0026\3\v\0009\3\f\0039\3\r\3'\5\14\0B\3\2\2'\4\15\0&\3\4\3=\3\16\0024\3\0\0=\3\17\2B\0\2\1K\0\1\0\26server_opts_overrides\24plugin_manager_path\22/site/pack/packer\tdata\fstdpath\afn\bvim\15suggestion\1\0\4\vaccept\n\tprev\n\tnext\n\fdismiss\n\1\0\3\17auto_trigger\2\rdebounce\3K\fenabled\2\npanel\1\0\1\25copilot_node_command\tnode\vkeymap\1\0\5\frefresh\agr\topen\v\14jump_next\a]]\vaccept\t\14jump_prev\a[[\1\0\2\17auto_refresh\1\fenabled\2\nsetup\fcopilot\frequire-\1\0\4\0\3\0\0066\0\0\0009\0\1\0003\2\2\0)\3d\0B\0\3\1K\0\1\0\0\rdefer_fn\bvim\0" }, load_after = {}, loaded = true, needs_bufread = false, @@ -176,6 +176,12 @@ _G.packer_plugins = { path = "/home/sudacode/.local/share/nvim/site/pack/packer/start/goto-preview", url = "https://github.com/rmagatti/goto-preview" }, + ["hover.nvim"] = { + config = { "\27LJ\2\nz\0\0\3\0\4\0\n6\0\0\0'\2\1\0B\0\2\0016\0\0\0'\2\2\0B\0\2\0016\0\0\0'\2\3\0B\0\2\1K\0\1\0\31hover.providers.dictionary\24hover.providers.man\24hover.providers.lsp\frequire°\2\1\0\a\0\17\0!6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\4\0003\3\3\0=\3\5\0025\3\6\0=\3\a\2B\0\2\0016\0\b\0009\0\t\0009\0\n\0'\2\v\0'\3\f\0006\4\0\0'\6\1\0B\4\2\0029\4\1\0045\5\r\0B\0\5\0016\0\b\0009\0\t\0009\0\n\0'\2\v\0'\3\14\0006\4\0\0'\6\1\0B\4\2\0029\4\15\0045\5\16\0B\0\5\1K\0\1\0\1\0\1\tdesc\24hover.nvim (select)\17hover_select\agK\1\0\1\tdesc\15hover.nvim\6K\6n\bset\vkeymap\bvim\17preview_opts\1\0\1\vborder\frounded\tinit\1\0\2\19preview_window\1\ntitle\2\0\nsetup\nhover\frequire\0" }, + loaded = true, + path = "/home/sudacode/.local/share/nvim/site/pack/packer/start/hover.nvim", + url = "https://github.com/lewis6991/hover.nvim" + }, ["lsp_lines.nvim"] = { loaded = true, path = "/home/sudacode/.local/share/nvim/site/pack/packer/start/lsp_lines.nvim", @@ -211,11 +217,6 @@ _G.packer_plugins = { path = "/home/sudacode/.local/share/nvim/site/pack/packer/start/nvim-cmp", url = "https://github.com/hrsh7th/nvim-cmp" }, - ["nvim-docs-view"] = { - loaded = true, - path = "/home/sudacode/.local/share/nvim/site/pack/packer/start/nvim-docs-view", - url = "https://github.com/amrbashir/nvim-docs-view" - }, ["nvim-lsp-installer"] = { loaded = true, path = "/home/sudacode/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer", @@ -304,18 +305,22 @@ _G.packer_plugins = { } time([[Defining packer_plugins]], false) +-- Config for: hover.nvim +time([[Config for hover.nvim]], true) +try_loadstring("\27LJ\2\nz\0\0\3\0\4\0\n6\0\0\0'\2\1\0B\0\2\0016\0\0\0'\2\2\0B\0\2\0016\0\0\0'\2\3\0B\0\2\1K\0\1\0\31hover.providers.dictionary\24hover.providers.man\24hover.providers.lsp\frequire°\2\1\0\a\0\17\0!6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\4\0003\3\3\0=\3\5\0025\3\6\0=\3\a\2B\0\2\0016\0\b\0009\0\t\0009\0\n\0'\2\v\0'\3\f\0006\4\0\0'\6\1\0B\4\2\0029\4\1\0045\5\r\0B\0\5\0016\0\b\0009\0\t\0009\0\n\0'\2\v\0'\3\14\0006\4\0\0'\6\1\0B\4\2\0029\4\15\0045\5\16\0B\0\5\1K\0\1\0\1\0\1\tdesc\24hover.nvim (select)\17hover_select\agK\1\0\1\tdesc\15hover.nvim\6K\6n\bset\vkeymap\bvim\17preview_opts\1\0\1\vborder\frounded\tinit\1\0\2\19preview_window\1\ntitle\2\0\nsetup\nhover\frequire\0", "config", "hover.nvim") +time([[Config for hover.nvim]], false) -- Load plugins in order defined by `after` time([[Sequenced loading]], true) vim.cmd [[ packadd lualine.nvim ]] vim.cmd [[ packadd copilot.lua ]] -- Config for: copilot.lua -try_loadstring("\27LJ\2\n‘\4\0\0\6\0\20\0\0276\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\6\0005\3\3\0005\4\4\0=\4\5\3=\3\a\0025\3\b\0005\4\t\0=\4\5\3=\3\n\0025\3\v\0=\3\f\0026\3\r\0009\3\14\0039\3\15\3'\5\16\0B\3\2\2'\4\17\0&\3\4\3=\3\18\0024\3\0\0=\3\19\2B\0\2\1K\0\1\0\26server_opts_overrides\24plugin_manager_path\22/site/pack/packer\tdata\fstdpath\afn\bvim\14filetypes\1\0\t\bsvn\1\rhgcommit\1\14gitrebase\1\14gitcommit\1\thelp\1\rmarkdown\1\tyaml\1\6.\1\bcvs\1\15suggestion\1\0\4\tnext\n\fdismiss\n\tprev\n\vaccept\n\1\0\3\rdebounce\3K\fenabled\2\17auto_trigger\2\npanel\1\0\1\25copilot_node_command\tnode\vkeymap\1\0\5\14jump_prev\a[[\frefresh\agr\vaccept\t\topen\v\14jump_next\a]]\1\0\2\17auto_refresh\1\fenabled\2\nsetup\fcopilot\frequire-\1\0\4\0\3\0\0066\0\0\0009\0\1\0003\2\2\0)\3d\0B\0\3\1K\0\1\0\0\rdefer_fn\bvim\0", "config", "copilot.lua") +try_loadstring("\27LJ\2\n¹\3\0\0\6\0\18\0\0256\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\6\0005\3\3\0005\4\4\0=\4\5\3=\3\a\0025\3\b\0005\4\t\0=\4\5\3=\3\n\0026\3\v\0009\3\f\0039\3\r\3'\5\14\0B\3\2\2'\4\15\0&\3\4\3=\3\16\0024\3\0\0=\3\17\2B\0\2\1K\0\1\0\26server_opts_overrides\24plugin_manager_path\22/site/pack/packer\tdata\fstdpath\afn\bvim\15suggestion\1\0\4\vaccept\n\tprev\n\tnext\n\fdismiss\n\1\0\3\17auto_trigger\2\rdebounce\3K\fenabled\2\npanel\1\0\1\25copilot_node_command\tnode\vkeymap\1\0\5\frefresh\agr\topen\v\14jump_next\a]]\vaccept\t\14jump_prev\a[[\1\0\2\17auto_refresh\1\fenabled\2\nsetup\fcopilot\frequire-\1\0\4\0\3\0\0066\0\0\0009\0\1\0003\2\2\0)\3d\0B\0\3\1K\0\1\0\0\rdefer_fn\bvim\0", "config", "copilot.lua") vim.cmd [[ packadd copilot-cmp ]] -- Config for: copilot-cmp -try_loadstring("\27LJ\2\n9\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\nsetup\16copilot_cmp\frequire\0", "config", "copilot-cmp") +try_loadstring("\27LJ\2\n¶\1\0\0\a\0\t\0\0146\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0005\3\6\0006\4\0\0'\6\4\0B\4\2\0029\4\5\4=\4\a\3=\3\b\2B\0\2\1K\0\1\0\15formatters\16insert_text\1\0\0\20remove_existing\23copilot_cmp.format\1\0\1\vmethod\26getCompletionsCycling\nsetup\16copilot_cmp\frequire\0", "config", "copilot-cmp") time([[Sequenced loading]], false)