From 227a06e002ab895f5e701189160bc950d39943c7 Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Thu, 27 Oct 2022 17:28:20 -0700 Subject: [PATCH] update vim config with telescope --- nvim/init.vim | 8 +- nvim/keybindings.vim | 68 ++++++++------ nvim/keybindings.vim.old | 133 +++++++++++++++++++++++++++ nvim/plugin-confs/bufferline.lua | 2 +- nvim/plugin-confs/doomone.lua | 84 +++++++++++------ nvim/plugin-confs/lspconfig.lua | 17 ++++ nvim/plugin-confs/nvim-cmp.lua | 2 +- nvim/plugin-confs/nvim-docs-view.lua | 6 ++ nvim/plugin-confs/nvimtree.lua | 2 +- nvim/plugin-confs/onedarkpro.lua | 13 +-- nvim/plugin-confs/telescope.lua | 43 +++++++++ 11 files changed, 303 insertions(+), 75 deletions(-) create mode 100644 nvim/keybindings.vim.old create mode 100644 nvim/plugin-confs/nvim-docs-view.lua create mode 100644 nvim/plugin-confs/telescope.lua diff --git a/nvim/init.vim b/nvim/init.vim index 698809b..d867ab0 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -90,10 +90,11 @@ if has('nvim') Plug 'kyazdani42/nvim-web-devicons' Plug 'lewis6991/gitsigns.nvim' Plug 'nvim-lualine/lualine.nvim' + Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.0' } Plug 'ojroques/nvim-lspfuzzy' Plug 'L3MON4D3/LuaSnip' - Plug 'folke/trouble.nvim' + Plug 'amrbashir/nvim-docs-view' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-path' @@ -106,7 +107,6 @@ if has('nvim') Plug 'ray-x/lsp_signature.nvim' Plug 'rmagatti/goto-preview', Plug 'saadparwaiz1/cmp_luasnip' - Plug 'simrat39/symbols-outline.nvim' Plug 'williamboman/nvim-lsp-installer' Plug 'Mofiqul/dracula.nvim' @@ -148,6 +148,7 @@ if has('nvim') source ~/.config/nvim/plugin-confs/presence.lua source ~/.config/nvim/plugin-confs/treesitter.lua source ~/.config/nvim/plugin-confs/whichkey.lua + source ~/.config/nvim/plugin-confs/telescope.lua source ~/.config/nvim/plugin-confs/code_actions.lua " source ~/.config/nvim/plugin-confs/copilot.lua @@ -160,12 +161,11 @@ if has('nvim') 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/trouble.lua + source ~/.config/nvim/plugin-confs/nvim-docs-view.lua " nvim and vim plugins source ~/.vim/plugin-confs/floaterm.vim source ~/.vim/plugin-confs/fzf.vim - source ~/.vim/plugin-confs/lightline.vim source ~/.vim/plugin-confs/vim-closetag.vim source ~/.vim/plugin-confs/wakatime.vim diff --git a/nvim/keybindings.vim b/nvim/keybindings.vim index f8c4b15..897c42e 100644 --- a/nvim/keybindings.vim +++ b/nvim/keybindings.vim @@ -22,15 +22,17 @@ nnoremap // :Lines nnoremap ?? :BLines nmap gA :lua vim.lsp.buf.code_actions() -nmap gDc :lua vim.lsp.buf.declaration() -nmap gDf :lua vim.lsp.buf.definition() +nmap gd :Telescope lsp_definitions +nmap gDc :Telescope lsp_implementations +nmap gDf :Telescope lsp_definitions nmap gF :edit -nmap gT :lua vim.lsp.buf.type_definition() +nmap gT :Telescope lsp_type_definitions nmap gb :Gitsigns blame_line " nmap gd :lua vim.lsp.buf.definition() -nmap gi :lua vim.lsp.buf.implementation() +nmap gi :Telescope lsp_implementations +nmap gj :Telescope jumplist nmap gl :lua vim.lsp.buf.code_lens() -nmap gr :lua vim.lsp.buf.references() +nmap gr :Telescope lsp_references nmap gs :lua vim.lsp.buf.signature_help() nmap Q !!$SHELL @@ -40,55 +42,60 @@ nmap rn :lua vim.lsp.buf.rename() nmap as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144 nmap ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144 -nmap bb :Buffers +nmap bb :Telescope buffers nmap bk :bdelete nmap bn :bnext nmap bp :bprev nmap ca :lua vim.lsp.buf.code_action() nmap cc :vert Copilot -nmap cd :LspDiagnostics -nmap cl :lua vim.lsp.diagnostic.show_line_diagnostics() +nmap cd :Telescope diagnostics +" nmap cl :lua vim.lsp.diagnostic.show_line_diagnostics() nnoremap cn :DashboardNewFile -nmap ff :CocCommand fzf-preview.ProjectFiles +nnoremap ff :Telescope find_files +nnoremap fg :Telescope live_grep +nnoremap fb :Telescope buffers +nnoremap fh :Telescope help_tags nmap fa :DashboardFindWord nmap fb :DashboardJumpMark nmap fh :DashboardFindHistory nmap gb :Gitsigns blame_line -nmap gc :Commits -nmap gf :GitFiles +nmap gc :Telescope git_commits +nmap gf :Telescope git_files " nmap gg :Neogit nmap gg :FloatermNew --title=lazygit --width=1.0 --height=1.0 --opener=vsplit lazygit nnoremap gP lua require('goto-preview').close_all_win() -nnoremap gR TroubleToggle lsp_references +nnoremap gR Telescope lsp_references nnoremap gpc lua require('goto-preview').close_all_win() nnoremap gpd lua require('goto-preview').goto_preview_definition() nnoremap gpi lua require('goto-preview').goto_preview_implementation() -nmap hc :Commands -nmap hh :Helptags -nmap hk :Maps +nmap hc :Telescope commands +nmap hh :Telescope tags +nmap hk :Telescope keymaps +nmap hs :Telescope spell_suggest nmap isp :-1read $HOME/Templates/python.py4jw nmap j :AnyJump -nmap K :lua vim.lsp.buf.hover() +nmap K :DocsViewToggle +" nmap K :lua vim.lsp.buf.hover() -nmap lD :lua vim.lsp.buf.definition() +nmap lD :Telescope lsp_definitions nmap la :lua vim.lsp.buf.code_action() -nmap lci :lua vim.lsp.buf.incoming_calls() -nmap lco :lua vim.lsp.buf.outgoing_calls() -nmap ld :lua vim.lsp.buf.declaration() +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 :lua vim.lsp.buf.implementation() -nmap lr :lua vim.lsp.buf.references() +nmap li :Telescope lsp_implementations +nmap lr :Telescope lsp_references nmap lR :lua vim.lsp.buf.rename() -nmap ls :lua vim.lsp.buf.document_symbol() -nmap lt :lua vim.lsp.buf.type_definition() -nmap lw :lua vim.lsp.buf.workspace_symbol() +nmap ls :Telescope lsp_document_symbols +nmap lt :Telescope lsp_type_definitions +nmap lw :Telescope lsp_dynamic_workspace_symbols nmap n :NvimTreeToggle @@ -106,13 +113,14 @@ nmap r :NvimTreeRefresh nmap sl :SessionLoad nmap ss :SessionSave -nmap sF :AllFiles nmap sc :nohls -nmap sf :Files -nmap sh :History: -nmap s/ :History/ +nmap sC :Telescope commands +nmap sf :Telescope find_files +nmap sh :Telescope command_history +nmap sm :Telescope man_pages +nmap s/ :Telescope search_history -nnoremap tc :DashboardChangeColorscheme +nnoremap tc :Telescope colorscheme nmap tf :wa:FloatermToggle floatterm nmap to :SymbolsOutline nmap tp :FloatermToggle ipython diff --git a/nvim/keybindings.vim.old b/nvim/keybindings.vim.old new file mode 100644 index 0000000..edfdc23 --- /dev/null +++ b/nvim/keybindings.vim.old @@ -0,0 +1,133 @@ +nmap :set paste!set paste? +nmap :! + +" reselect visual selection after indent +vnoremap < >gv + +" for toggling/hiding the split-term +tnoremap :FloatermToggle floatterm +tnoremap +tnoremap tt :FloatermToggle split-term +tnoremap tf :FloatermToggle floatterm +tnoremap tp :FloatermToggle ipython +tnoremap tP :FloatermToggle ipython-full + +nmap :bnext +nmap :bprev +nmap :wa:FloatermToggle floatterm + +" open file under cursor, create if necessary +nnoremap // :Lines +nnoremap ?? :BLines + +nmap gA :lua vim.lsp.buf.code_actions() +nmap gDc :lua vim.lsp.buf.declaration() +nmap gDf :lua vim.lsp.buf.definition() +nmap gF :edit +nmap gT :lua vim.lsp.buf.type_definition() +nmap gb :Gitsigns blame_line +" nmap gd :lua vim.lsp.buf.definition() +nmap gi :lua vim.lsp.buf.implementation() +nmap gl :lua vim.lsp.buf.code_lens() +nmap gr :lua vim.lsp.buf.references() +nmap gs :lua vim.lsp.buf.signature_help() + +nmap Q !!$SHELL + +nmap rn :lua vim.lsp.buf.rename() + +nmap as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144 +nmap ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144 + +nmap bb :Buffers +nmap bk :bdelete +nmap bn :bnext +nmap bp :bprev + +nmap ca :lua vim.lsp.buf.code_action() +nmap cc :vert Copilot +nmap cd :LspDiagnostics +nmap cl :lua vim.lsp.diagnostic.show_line_diagnostics() +nnoremap cn :DashboardNewFile + +nmap ff :CocCommand fzf-preview.ProjectFiles +nmap fa :DashboardFindWord +nmap fb :DashboardJumpMark +nmap fh :DashboardFindHistory + +nmap gb :Gitsigns blame_line +nmap gc :Commits +nmap gf :GitFiles +" nmap gg :Neogit +nmap gg :FloatermNew --title=lazygit --width=1.0 --height=1.0 --opener=vsplit lazygit +nnoremap gP lua require('goto-preview').close_all_win() +nnoremap gR TroubleToggle lsp_references +nnoremap gpc lua require('goto-preview').close_all_win() +nnoremap gpd lua require('goto-preview').goto_preview_definition() +nnoremap gpi lua require('goto-preview').goto_preview_implementation() + +nmap hc :Commands +nmap hh :Helptags +nmap hk :Maps + +nmap isp :-1read $HOME/Templates/python.py4jw + +nmap j :AnyJump + +nmap K :lua vim.lsp.buf.hover() + +nmap lD :lua vim.lsp.buf.definition() +nmap la :lua vim.lsp.buf.code_action() +nmap lci :lua vim.lsp.buf.incoming_calls() +nmap lco :lua vim.lsp.buf.outgoing_calls() +nmap ld :lua vim.lsp.buf.declaration() +nmap lh :lua vim.lsp.buf.signature_help() +nmap li :lua vim.lsp.buf.implementation() +nmap lr :lua vim.lsp.buf.references() +nmap lR :lua vim.lsp.buf.rename() +nmap ls :lua vim.lsp.buf.document_symbol() +nmap lt :lua vim.lsp.buf.type_definition() +nmap lw :lua vim.lsp.buf.workspace_symbol() + +nmap n :NvimTreeToggle + +nmap ob :FloatermNew --title=bpytop --opener=vsplit bpytop +nmap od :FloatermNew --title=lazydocker --opener=vsplit lazydocker +nmap of :wa:FloatermToggle floatterm +nmap oh :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=split --position=botright --height=0.45 +nmap on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp +nmap op :FloatermNew --title=ipython --name=ipython --opener=split --wintype=vsplit --position=botright --width=0.5 ipython +nmap oP :FloatermNew --title=ipython-full --name=ipython-full --opener=edit --width=1.0 --height=1.0 ipython +nmap or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD" +nmap ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5 + +nmap r :NvimTreeRefresh + +nmap sl :SessionLoad +nmap ss :SessionSave +nmap sF :AllFiles +nmap sc :nohls +nmap sf :Files +nmap sh :History: +nmap s/ :History/ + +nnoremap tc :Colors +nmap tf :wa:FloatermToggle floatterm +nmap to :SymbolsOutline +nmap tp :FloatermToggle ipython +nmap tP :FloatermToggle ipython-full +nmap tt :FloatermToggle split-term + +nmap wa :lua vim.lsp.buf.add_workspace_folder() +nmap wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders())) +nmap wr :lua vim.lsp.buf.remove_workspace_folder() + +" nnoremap xd TroubleToggle document_diagnostics +" nnoremap xl TroubleToggle loclist +" nnoremap xq TroubleToggle quickfix +" nnoremap xw TroubleToggle workspace_diagnostics +" nnoremap xx TroubleToggle + +nmap y "+ +vmap y "+ diff --git a/nvim/plugin-confs/bufferline.lua b/nvim/plugin-confs/bufferline.lua index 8d87a98..f01aa3d 100644 --- a/nvim/plugin-confs/bufferline.lua +++ b/nvim/plugin-confs/bufferline.lua @@ -35,7 +35,7 @@ require('bufferline').setup { max_prefix_length = 15, -- prefix used when a buffer is de-duplicated tab_size = 18, -- diagnostics = false | "nvim_lsp" | "coc", - diagnostics = "coc", + diagnostics = "nvim_lsp", diagnostics_update_in_insert = false, diagnostics_indicator = function(count, level, diagnostics_dict, context) local s = " " diff --git a/nvim/plugin-confs/doomone.lua b/nvim/plugin-confs/doomone.lua index a9c3dcd..0e11b3e 100644 --- a/nvim/plugin-confs/doomone.lua +++ b/nvim/plugin-confs/doomone.lua @@ -1,27 +1,57 @@ -require('doom-one').setup({ - cursor_coloring = false, - terminal_colors = false, - italic_comments = false, - enable_treesitter = true, - transparent_background = false, - pumblend = { - enable = true, - transparency_amount = 20, - }, - plugins_integrations = { - neorg = true, - barbar = true, - bufferline = false, - gitgutter = false, - gitsigns = true, - telescope = false, - neogit = true, - nvim_tree = true, - dashboard = true, - startify = true, - whichkey = true, - indent_blankline = true, - vim_illuminate = true, - lspsaga = false, - }, - }) +-- require('doom-one').setup({ +-- cursor_coloring = false, +-- terminal_colors = false, +-- italic_comments = false, +-- enable_treesitter = true, +-- transparent_background = false, +-- pumblend = { +-- enable = true, +-- transparency_amount = 20, +-- }, +-- plugins_integrations = { +-- neorg = true, +-- barbar = true, +-- bufferline = false, +-- gitgutter = false, +-- gitsigns = true, +-- telescope = false, +-- neogit = true, +-- nvim_tree = true, +-- dashboard = true, +-- startify = true, +-- whichkey = true, +-- indent_blankline = true, +-- vim_illuminate = true, +-- lspsaga = false, +-- }, +-- }) + + +vim.g.doom_one_cursor_coloring = true +-- Set :terminal colors +vim.g.doom_one_terminal_colors = true +-- Enable italic comments +vim.g.doom_one_italic_comments = false +-- Enable TS support +vim.g.doom_one_enable_treesitter = true +-- Color whole diagnostic text or only underline +vim.g.doom_one_diagnostics_text_color = true +-- Enable transparent background +vim.g.doom_one_transparent_background = false + +-- Pumblend transparency +vim.g.doom_one_pumblend_enable = false +vim.g.doom_one_pumblend_transparency = 20 + +-- Plugins integration +vim.g.doom_one_plugin_neorg = true +vim.g.doom_one_plugin_barbar = false +vim.g.doom_one_plugin_telescope = false +vim.g.doom_one_plugin_neogit = true +vim.g.doom_one_plugin_nvim_tree = true +vim.g.doom_one_plugin_dashboard = true +vim.g.doom_one_plugin_startify = true +vim.g.doom_one_plugin_whichkey = true +vim.g.doom_one_plugin_indent_blankline = true +vim.g.doom_one_plugin_vim_illuminate = true +vim.g.doom_one_plugin_lspsaga = false diff --git a/nvim/plugin-confs/lspconfig.lua b/nvim/plugin-confs/lspconfig.lua index 25735c6..7f0e5b6 100644 --- a/nvim/plugin-confs/lspconfig.lua +++ b/nvim/plugin-confs/lspconfig.lua @@ -196,4 +196,21 @@ for _, lsp in pairs(servers) do } end +local plugins_path = vim.fn.stdpath("data") .. "site/autoload/plug.vim" +local dir_list = vim.fn.glob(plugins_path .. "/*", true, true) +local library_table = {} +for _, v in ipairs(dir_list) do + library_table[v .. "/lua"] = true +end +library_table[vim.fn.expand("$VIMRUNTIME/lua")] = true +library_table[vim.fn.stdpath("config") .. "/lua"] = true +require('lspconfig').sumneko_lua.setup({ + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + workspace = { library = library_table }, + }, + }, +}) + -- require 'lspconfig'.bashls.setup {} diff --git a/nvim/plugin-confs/nvim-cmp.lua b/nvim/plugin-confs/nvim-cmp.lua index d551e60..e8c3ddc 100644 --- a/nvim/plugin-confs/nvim-cmp.lua +++ b/nvim/plugin-confs/nvim-cmp.lua @@ -3,7 +3,7 @@ local cmp = require 'cmp' local lspkind = require('lspkind') local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) -- luasnip setup local luasnip = require 'luasnip' diff --git a/nvim/plugin-confs/nvim-docs-view.lua b/nvim/plugin-confs/nvim-docs-view.lua new file mode 100644 index 0000000..c4cc71b --- /dev/null +++ b/nvim/plugin-confs/nvim-docs-view.lua @@ -0,0 +1,6 @@ +require("docs-view").setup { + -- position = "right", + -- width = 90, + position = "bottom", + height = 20, +} diff --git a/nvim/plugin-confs/nvimtree.lua b/nvim/plugin-confs/nvimtree.lua index c218e5c..6de2dfe 100644 --- a/nvim/plugin-confs/nvimtree.lua +++ b/nvim/plugin-confs/nvimtree.lua @@ -40,7 +40,7 @@ require 'nvim-tree'.setup { }, view = { width = 35, - height = 35, + -- height = 35, hide_root_folder = false, side = 'left', -- auto_resize = false, diff --git a/nvim/plugin-confs/onedarkpro.lua b/nvim/plugin-confs/onedarkpro.lua index 60512a5..3931cc7 100644 --- a/nvim/plugin-confs/onedarkpro.lua +++ b/nvim/plugin-confs/onedarkpro.lua @@ -1,21 +1,12 @@ local onedarkpro = require("onedarkpro") onedarkpro.setup({ - -- Theme can be overwritten with 'onedark' or 'onelight' as a string! - -- theme = function() - -- if vim.o.background == "dark" then - -- return "onedark" - -- else - -- return "onelight" - -- end - -- end, theme = "onedark", - colors = {}, -- Override default colors. Can specify colors for "onelight" or "onedark" themes by passing in a table - hlgroups = {}, -- Override default highlight groups + -- colors = {}, -- Override default colors. Can specify colors for "onelight" or "onedark" themes by passing in a table + -- hlgroups = {}, -- Override default highlight groups plugins = { -- Override which plugins highlight groups are loaded native_lsp = true, polygot = true, treesitter = true, - -- Others omitted for brevity }, styles = { comments = "italic", diff --git a/nvim/plugin-confs/telescope.lua b/nvim/plugin-confs/telescope.lua new file mode 100644 index 0000000..5f06ed9 --- /dev/null +++ b/nvim/plugin-confs/telescope.lua @@ -0,0 +1,43 @@ +require('telescope').setup{ + defaults = { + -- Default configuration for telescope goes here: + -- config_key = value, + layout_strategy = 'flex', + width = 0.9, + wrap_results = true, + preview = { + border = true, + borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' }, + title = true, + dynamic_preview_title = true, + treesitter = true, + }, + mappings = { + i = { + -- map actions.which_key to (default: ) + -- actions.which_key shows the mappings for your picker, + -- e.g. git_{create, delete, ...}_branch for the git_branches picker + [""] = "which_key" + } + } + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + find_files = { + -- theme = "dropdown" + } + }, + extensions = { + -- Your extension configuration goes here: + -- extension_name = { + -- extension_config_key = value, + -- } + -- please take a look at the readme of the extension you want to configure + } +}