From 6f78887641aea2e6da1b8fd03c972f4e9bc3ff9c Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Mon, 27 Sep 2021 15:27:03 +0700 Subject: [PATCH] neovim: changes a bunch - undodir: move to stdpath('data') to be more inline with other - add todo-comments.nvim - whichkey: rebind for hop.nvim (avoid conflicting with vim-sandwich blockwise) - mappings: clean up and rearrange --- home/.config/nvim/lua/colors/nord.lua | 7 ++++ home/.config/nvim/lua/mappings.lua | 56 ++++++++++++++++----------- home/.config/nvim/lua/modules/lsp.lua | 52 +++++++++++++++++++++++++ home/.config/nvim/lua/options.lua | 2 +- home/.config/nvim/lua/plugins.lua | 10 ++++- 5 files changed, 101 insertions(+), 26 deletions(-) diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/colors/nord.lua index 704fceb..ba644a9 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -297,6 +297,13 @@ local function highlight_plugins() hi('rainbowcol6', c.blue, '', 'bold', '') hi('rainbowcol7', c.purple, '', 'bold', '') + -- todo-comments + hi('TodoDefault', c.fg, '', 'bold', '') + hi('TodoError', c.red, '', 'bold', '') + hi('TodoWarn', c.yellow, '', 'bold', '') + hi('TodoInfo', c.blue, '', 'bold', '') + hi('TodoHint', c.cyan, '', 'bold', '') + -- hop.nvim hi('HopNextKey', c.red, '', 'bold', '') hi('HopNextKey1', c.cyan, '', 'bold', '') diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 217b0d0..252723a 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -11,9 +11,6 @@ api.nvim_set_keymap('t', '', '', {noremap = true, silent = true} api.nvim_set_keymap('v', '<', '', '>gv', {noremap = true, silent = true}) --- Clear search results --- api.nvim_set_keymap('n', '', 'noh', {noremap = true, silent = true}) - -- vim-eft api.nvim_set_keymap('n', 'f', '(eft-f)', {}) api.nvim_set_keymap('x', 'f', '(eft-f)', {}) @@ -47,9 +44,6 @@ wk.register({ -- Copy the whole buffer [''] = {'%y+', 'Copy whole buffer'}, - -- 'Legacy' save buffer - -- [''] = {':w', 'Write buffer'}, - -- Close buffer [''] = {':bd!', 'Close buffer'}, @@ -113,8 +107,8 @@ wk.register({ [''] = {':ToggleTerm direction=float', 'Toggle float terminal'}, -- hop.nvim - s = {':HopWord', 'Hop to word'}, - S = {':HopChar1', 'Hop to character'}, + S = {':HopWord', 'Hop to word'}, + [''] = {':HopChar1', 'Hop to character'}, [''] = {':HopPattern', 'Hop to pattern'} }) @@ -122,16 +116,21 @@ wk.register({ -- Normal mode (with leader key) -- ----------------------------------- wk.register({ + a = {':EasyAlign', 'Align'}, + b = { - name = 'Buffer', - a = {':EasyAlign', 'Easy align'}, + name = 'Buffer/Tab', c = {':ColorizerToggle', 'Colorizer'}, d = {':bdelete', 'Close buffer'}, j = {':BufferLineCyclePrev', 'Previous buffer'}, k = {':BufferLineCycleNext', 'Next buffer'}, n = {':enew', 'New buffer'}, u = {':UndotreeToggle', 'Undotree'}, - z = {':ZenMode', 'Zen mode'} + z = {':ZenMode', 'Zen mode'}, + D = {'tabclose', 'Close tab'}, + J = {'tabprev', 'Previous tab'}, + K = {'tabnext', 'Next tab'}, + N = {'tabnew', 'New tab'} }, d = { @@ -244,7 +243,8 @@ wk.register({ e = {':TroubleToggle lsp_document_diagnostics', 'Document diagnostics list'}, w = {':TroubleToggle lsp_workspace_diagnostics', 'Workspace diagnostics list'}, l = {':TroubleToggle loclist', 'Location list items'}, - q = {':TroubleToggle quickfix', 'Quickfix list'} + q = {':TroubleToggle quickfix', 'Quickfix list'}, + t = {':TroubleToggle', 'Summary'} } }, @@ -262,13 +262,26 @@ wk.register({ w = {':lua require("spectre").open_visual({select_word = true})', 'Find/replace cursorword'}, }, - -- Tab related - t = { - name = 'Tab', - c = {'tabclose', 'Close tab'}, - j = {'tabprev', 'Previous tab'}, - k = {'tabnext', 'Next tab'}, - n = {'tabnew', 'New tab'} + -- t = { + -- name = 'Todo', + -- f = {':TodoQuickFix', 'Quick fix'}, + -- l = {':TodoLocList', 'Loclist'}, + -- t = {':TodoTrouble', 'Open in Trouble'}, + -- z = {':TodoTelescope', 'Open in Telescope'} + -- }, + + y ={ + name = 'Figlet', + s = {':.!figlet -f standard', 'standard'}, + l = {':.!figlet -f slant', 'slant'}, + b = {':.!figlet -f banner', 'banner'}, + e = {':.!figlet -f lean', 'lean'}, + p = {':.!figlet -f speed', 'speed'}, + r = {':.!figlet -f roman', 'roman'}, + d = {':.!figlet -f doh', 'doh'}, + w = {':.!figlet -f starwars', 'starwars'}, + m = {':.!figlet -f morse', 'morse'}, + x = {':.!toilet -f term -F border', 'border'} } }, {prefix = ''}) @@ -276,10 +289,7 @@ wk.register({ -- Visual mode (with leader key) -- ----------------------------------- wk.register({ - b = { - name = 'Buffer', - a = {':EasyAlign', 'Range easy align'} - }, + a = {':EasyAlign', 'Range align'}, d = { name = 'DAP', diff --git a/home/.config/nvim/lua/modules/lsp.lua b/home/.config/nvim/lua/modules/lsp.lua index 864c172..a93a7cc 100644 --- a/home/.config/nvim/lua/modules/lsp.lua +++ b/home/.config/nvim/lua/modules/lsp.lua @@ -200,6 +200,58 @@ function M.trouble_conf() } end +-- function M.comments_conf() +-- require('todo-comments').setup { +-- signs = false, +-- -- sign_priority = 8, +-- keywords = { +-- FIX = { +-- icon = ' ', -- icon used for the sign, and in search results +-- color = 'error', -- can be a hex color, or a named color (see below) +-- alt = {'FIXME', 'BUG', 'FIXIT', 'ISSUE'}, -- a set of other keywords that all map to this FIX keywords +-- -- signs = false, -- configure signs for some keywords individually +-- }, +-- TODO = {icon = ' ', color = 'info'}, +-- HACK = {icon = ' ', color = 'warning'}, +-- WARN = {icon = ' ', color = 'warning', alt = {'WARNING', 'XXX'}}, +-- PERF = {icon = ' ', alt = {'OPTIM', 'PERFORMANCE', 'OPTIMIZE'}}, +-- NOTE = {icon = ' ', color = 'hint', alt = {'INFO'}}, +-- }, +-- merge_keywords = true, +-- highlight = { +-- before = '', -- 'fg' or 'bg' or empty +-- keyword = 'fg', -- 'fg', 'bg', 'wide' or empty. (wide is the same as bg, but will also highlight surrounding characters) +-- after = '', -- 'fg' or 'bg' or empty +-- pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlightng (vim regex) +-- comments_only = true, -- uses treesitter to match keywords in comments only +-- max_line_len = 400, -- ignore lines longer than this +-- exclude = {'org'}, -- list of file types to exclude highlighting +-- }, +-- colors = { +-- error = {'TodoError', 'Red'}, +-- warning = {'TodoWarn', 'Yellow'}, +-- info = {'TodoInfo', 'Blue'}, +-- hint = {'TodoHint', 'Cyan'}, +-- default = {'TodoDefault', 'White'} +-- }, +-- search = { +-- command = 'rg', +-- args = { +-- '--hidden', +-- '--color=never', +-- '--no-heading', +-- '--with-filename', +-- '--line-number', +-- '--column', +-- }, +-- -- regex that will be used to match keywords. +-- -- don't replace the (KEYWORDS) placeholder +-- pattern = [[\b(KEYWORDS):]] -- ripgrep regex +-- -- pattern = [[\b(KEYWORDS)\b]] -- match without the extra colon. You'll likely get false positives +-- } +-- } +-- end + function M.outline_conf() vim.g.symbols_outline = { highlight_hovered_item = false, diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index e895a46..798a9c3 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -150,7 +150,7 @@ function M.load_options() -- Undo file path opt.undofile = true - opt.undodir = vim.fn.stdpath('cache') .. '/undodir' + opt.undodir = vim.fn.stdpath('data') .. '/undodir' end return M diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 2c0c49b..a8ca6fb 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -119,7 +119,7 @@ return require('packer').startup( } use { 'machakann/vim-sandwich', - keys = {'sa', 'sd', 'sr'} + keys = 's' } use { 'phaazon/hop.nvim', @@ -177,6 +177,12 @@ return require('packer').startup( cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'}, config = lsp.trouble_conf } + -- use { -- FIX: conflict highlights with hop.nvim + -- 'folke/todo-comments.nvim', + -- wants = 'plenary.nvim', + -- event = 'BufRead', + -- config = lsp.comments_conf + -- } use { 'simrat39/symbols-outline.nvim', cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'}, @@ -392,6 +398,6 @@ return require('packer').startup( -- use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking -- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, - -- vim-pandoc, nvim-bqf, todo-comments.nvim, nvim-comment-frame + -- vim-pandoc, nvim-bqf, nvim-comment-frame end )