From d0ea29e2b522de1f8975ae8ccb6862a8eb77bbe6 Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Wed, 16 Aug 2023 02:29:56 -0700 Subject: [PATCH] add color names, highlighing on hover, and keybindings --- keybindings.vim | 27 ++++---- lua/plugins.lua | 43 +------------ plugin-confs/dashboard-nvim.lua | 105 ++++++++++++++++++++++++-------- plugin-confs/nvim-cmp.lua | 26 +++++++- plugin-confs/telescope.lua | 2 + plugin-confs/whichkey.lua | 8 +++ 6 files changed, 133 insertions(+), 78 deletions(-) diff --git a/keybindings.vim b/keybindings.vim index 3ebfb97..b3a0a91 100644 --- a/keybindings.vim +++ b/keybindings.vim @@ -36,7 +36,7 @@ nnoremap gA :lua vim.lsp.buf.code_actions() nnoremap gd :Telescope lsp_definitions nnoremap gDc :Telescope lsp_implementations nnoremap gDf :Telescope lsp_definitions -nnoremap gF :edit +nnoremap gF :edit nnoremap gT :Telescope lsp_type_definitions nnoremap gb :Gitsigns blame_line nnoremap gi :Telescope lsp_implementations @@ -105,17 +105,18 @@ nnoremap ek :e ~/.config/nvim/keybindings.vim nnoremap ep :e ~/.config/nvim/lua/plugins.lua nnoremap es :e ~/.config/nvim/lua/settings.lua -nnoremap fb :Telescope file_browser -nnoremap ff :Telescope find_files -nnoremap fg :Telescope live_grep -nnoremap fr :Telescope oldfiles +nnoremap fb :Telescope file_browser +nnoremap fc :Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical +nnoremap ff :Telescope find_files +nnoremap fg :Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical +nnoremap fr :Telescope oldfiles nnoremap gb :Gitsigns blame_line nnoremap gc :Telescope git_commits nnoremap gf :Telescope git_files nnoremap gg :FloatermNew --title=lazygit --width=1.0 --height=1.0 --opener=vsplit lazygit nnoremap gP lua require('goto-preview').close_all_win() -nnoremap gR Telescope 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() @@ -126,7 +127,7 @@ nnoremap hdC :Telescope dap configurations nnoremap hdb :Telescope dap list_breakpoints nnoremap hdv :Telescope dap variables nnoremap hdf :Telescope dap frames -nnoremap hv :Telescope vim_options +nnoremap hv :Telescope vim_options nnoremap hk :Telescope keymaps nnoremap hs :Telescope spell_suggest @@ -166,10 +167,10 @@ nnoremap oP :FloatermNew --title=ipython-full --name=ipython-full --open nnoremap or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD" nnoremap ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5 -nnoremap sc :nohls -nnoremap sC :Telescope commands -nnoremap sf :Telescope find_files -nnoremap sg :Telescope glyph +nnoremap sc :nohls +nnoremap sC :Telescope commands +nnoremap sf :Telescope find_files +nnoremap sg :Telescope live_grep nnoremap sh :Telescope command_history nnoremap sm :Telescope man_pages nnoremap s/ :Telescope search_history @@ -180,6 +181,10 @@ nnoremap tp :FloatermToggle ipython nnoremap tP :FloatermToggle ipython-full nnoremap tt :FloatermToggle split-term nnoremap td :DBUIToggle +nnoremap Tc :Telescope color_names theme=dropdown layout_config={width=0.45,height=25,prompt_position="bottom"} layout_strategy=vertical +nnoremap Tg :Telescope glyph theme=dropdown layout_config={width=0.45,height=35,prompt_position="bottom"} layout_strategy=vertical +nnoremap Tn :Telescope notify +nnoremap Tt :Telescope nnoremap wa :lua vim.lsp.buf.add_workspace_folder() nnoremap wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders())) diff --git a/lua/plugins.lua b/lua/plugins.lua index 52a343b..0101c9f 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -17,6 +17,7 @@ require('packer').startup(function(use) use { 'nvim-telescope/telescope-file-browser.nvim' } use 'nvim-telescope/telescope-dap.nvim' use { 'ghassan0/telescope-glyph.nvim' } + use { 'nat-418/telescope-color-names.nvim' } use { 'nvim-telescope/telescope-fzf-native.nvim', run = @@ -268,48 +269,6 @@ require('packer').startup(function(use) use { 'glepnir/dashboard-nvim', -- event = 'VimEnter', - config = function() - require('dashboard').setup { - theme = 'doom', -- theme is doom and hyper default is hyper - disable_move = false, -- default is false disable move keymap for hyper - shortcut_type = 'number', -- shorcut type 'letter' or 'number' - change_to_vcs_root = false, -- default is false,for open file in hyper mru. it will change to the root of vcs - config = { - header = { "NVIM DASHBOARD" }, -- your header - center = { - { - icon = ' ', - icon_hl = 'Title', - desc = 'Find File ', - desc_hl = 'String', - key = 'b', - keymap = 'SPC f f', - key_hl = 'Number', - action = 'lua print(2)' - } - -- { - -- icon = ' ', - -- desc = 'Find Dotfiles', - -- key = 'f', - -- keymap = 'SPC f d', - -- action = 'lua print(3)' - -- } - }, - footer = {} -- your footer - }, - hide = { - statusline = true, -- hide statusline default is true - tabline = true, -- hide the tabline - winbar = true -- hide winbar - } - -- preview = { - -- command = "bat", -- preview command - -- file_path -- preview file path - -- file_height -- preview file height - -- file_width -- preview file width - -- }, - } - end, requires = { 'nvim-tree/nvim-web-devicons' } } use { diff --git a/plugin-confs/dashboard-nvim.lua b/plugin-confs/dashboard-nvim.lua index c9a0b60..82586b9 100644 --- a/plugin-confs/dashboard-nvim.lua +++ b/plugin-confs/dashboard-nvim.lua @@ -9,28 +9,85 @@ local db = require('dashboard') -- db.preview_file_width = 70 vim.cmd('source $HOME/.config/nvim/static/nvim-dashboard.vim') db.custom_center = { - {icon = ' ', - desc = 'Recently latest session ', - shortcut = 'SPC s l', - action ='SessionLoad'}, - {icon = ' ', - desc = 'Recently opened files ', - action = 'Telescope oldfiles', - shortcut = 'SPC f h'}, - {icon = ' ', - desc = 'Find File ', - action = 'Telescope find_files find_command=rg,--hidden,--files', - shortcut = 'SPC f f'}, - {icon = ' ', - desc ='File Browser ', - action = 'Telescope file_browser', - shortcut = 'SPC f b'}, - {icon = ' ', - desc = 'Find word ', - action = 'Telescope live_grep', - shortcut = 'SPC f w'}, - {icon = ' ', - desc = 'Open Personal dotfiles ', - action = ':e ~/.config/nvim/init.vim', - shortcut = 'SPC f d'}, + { + icon = ' ', + desc = 'Recently latest session ', + shortcut = 'SPC s l', + action = 'SessionLoad' + }, { + icon = ' ', + desc = 'Recently opened files ', + action = 'Telescope oldfiles', + shortcut = 'SPC f h' +}, { + desc = 'Find File ', + icon = ' ', + action = 'Telescope find_files find_command=rg,--hidden,--files', + shortcut = 'SPC f f' +}, { + icon = ' ', + desc = 'File Browser ', + action = 'Telescope file_browser', + shortcut = 'SPC f b' +}, { + icon = ' ', + desc = 'Find word ', + action = 'Telescope live_grep', + shortcut = 'SPC f w' +}, { + icon = ' ', + desc = 'Open Personal dotfiles ', + action = ':e ~/.config/nvim/init.vim', + shortcut = 'SPC f d' +} +} +require('dashboard').setup { + theme = 'doom', -- theme is doom and hyper default is hyper + disable_move = false, -- default is false disable move keymap for hyper + shortcut_type = 'number', -- shorcut type 'letter' or 'number' + change_to_vcs_root = false, -- default is false,for open file in hyper mru. it will change to the root of vcs + config = { + header = { "NVIM DASHBOARD" }, -- your header + center = { + { + icon = ' ', + icon_hl = 'Title', + desc = 'Open Recent', + desc_hl = 'String', + key = '1', + keymap = 'SPC f r', + key_hl = 'Number', + action = 'lua print(1)' + }, { + icon = ' ', + icon_hl = 'Title', + desc = 'Find File', + desc_hl = 'String', + key = '2', + key_hl = 'Number', + keymap = 'SPC f f', + action = 'lua print(2)' + } + + -- { + -- icon = ' ', + -- desc = 'Find Dotfiles', + -- key = 'f', + -- keymap = 'SPC f d', + -- action = 'lua print(3)' + -- } + }, + footer = {} -- your footer + }, + hide = { + statusline = true, -- hide statusline default is true + tabline = true, -- hide the tabline + winbar = true -- hide winbar + } + -- preview = { + -- command = "bat", -- preview command + -- file_path -- preview file path + -- file_height -- preview file height + -- file_width -- preview file width + -- }, } diff --git a/plugin-confs/nvim-cmp.lua b/plugin-confs/nvim-cmp.lua index f42cb0a..19c2cd6 100644 --- a/plugin-confs/nvim-cmp.lua +++ b/plugin-confs/nvim-cmp.lua @@ -6,6 +6,29 @@ local lspconfig = require('lspconfig') local luasnip = require 'luasnip' local highlight = require('cmp.utils.highlight') +local highlight_symbol_under_cursor = function() + vim.cmd [[ + hi! LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow + hi! LspReferenceText cterm=bold ctermbg=red guibg=LightYellow + hi! LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow + ]] + vim.api.nvim_create_augroup('lsp_document_highlight', { clear = false }) + vim.api.nvim_clear_autocmds({ + buffer = bufnr, + group = 'lsp_document_highlight' + }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + group = 'lsp_document_highlight', + buffer = bufnr, + callback = vim.lsp.buf.document_highlight + }) + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + group = 'lsp_document_highlight', + buffer = bufnr, + callback = vim.lsp.buf.clear_references + }) +end + local has_words_before = function() if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false @@ -221,12 +244,13 @@ for _, lsp in ipairs(servers) do if lsp == 'lua_ls' then lspconfig[lsp].setup { -- on_attach = my_custom_on_attach, + on_attach = highlight_symbol_under_cursor(), capabilities = capabilities, callSnippet = "Replace" } else lspconfig[lsp].setup { - -- on_attach = my_custom_on_attach, + on_attach = highlight_symbol_under_cursor(), capabilities = capabilities } end diff --git a/plugin-confs/telescope.lua b/plugin-confs/telescope.lua index cce00a2..5c67b30 100644 --- a/plugin-confs/telescope.lua +++ b/plugin-confs/telescope.lua @@ -63,3 +63,5 @@ ts.setup({ ts.load_extension('dap') ts.load_extension('fzf') ts.load_extension('glyph') +ts.load_extension('color_names') +ts.load_extension('notify') diff --git a/plugin-confs/whichkey.lua b/plugin-confs/whichkey.lua index faf9445..5bee1a9 100755 --- a/plugin-confs/whichkey.lua +++ b/plugin-confs/whichkey.lua @@ -123,6 +123,7 @@ wk.register({ f = { name = "Find File", b = "File Browser", + c = "File Color", f = "Find in Current Directory", g = "Live Grep", r = "File Recent" @@ -207,6 +208,13 @@ wk.register({ P = "Ipython (fullscreen)", t = "Split Terminal" }, + T = { + name = "Telescope", + c = "Color Names", + g = "Glyph", + n = "Notifications", + t = "Telescope" + }, w = { name = "Workspace", a = "Add Folder",