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
This commit is contained in:
FollieHiyuki 2021-09-27 15:27:03 +07:00
parent 8c725aa77c
commit 6f78887641
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
5 changed files with 101 additions and 26 deletions

View File

@ -297,6 +297,13 @@ local function highlight_plugins()
hi('rainbowcol6', c.blue, '', 'bold', '') hi('rainbowcol6', c.blue, '', 'bold', '')
hi('rainbowcol7', c.purple, '', '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 -- hop.nvim
hi('HopNextKey', c.red, '', 'bold', '') hi('HopNextKey', c.red, '', 'bold', '')
hi('HopNextKey1', c.cyan, '', 'bold', '') hi('HopNextKey1', c.cyan, '', 'bold', '')

View File

@ -11,9 +11,6 @@ api.nvim_set_keymap('t', '<Esc>', '<C-\\><C-n>', {noremap = true, silent = true}
api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true}) api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true}) api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true})
-- Clear search results
-- api.nvim_set_keymap('n', '<Esc>', '<Cmd>noh<CR>', {noremap = true, silent = true})
-- vim-eft -- vim-eft
api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {}) api.nvim_set_keymap('n', 'f', '<Plug>(eft-f)', {})
api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {}) api.nvim_set_keymap('x', 'f', '<Plug>(eft-f)', {})
@ -47,9 +44,6 @@ wk.register({
-- Copy the whole buffer -- Copy the whole buffer
['<C-a>'] = {'<Cmd>%y+<CR>', 'Copy whole buffer'}, ['<C-a>'] = {'<Cmd>%y+<CR>', 'Copy whole buffer'},
-- 'Legacy' save buffer
-- ['<C-s>'] = {':w<CR>', 'Write buffer'},
-- Close buffer -- Close buffer
['<C-x>'] = {':bd!<CR>', 'Close buffer'}, ['<C-x>'] = {':bd!<CR>', 'Close buffer'},
@ -113,8 +107,8 @@ wk.register({
['<A-\\>'] = {':ToggleTerm direction=float<CR>', 'Toggle float terminal'}, ['<A-\\>'] = {':ToggleTerm direction=float<CR>', 'Toggle float terminal'},
-- hop.nvim -- hop.nvim
s = {':HopWord<CR>', 'Hop to word'}, S = {':HopWord<CR>', 'Hop to word'},
S = {':HopChar1<CR>', 'Hop to character'}, ['<C-s>'] = {':HopChar1<CR>', 'Hop to character'},
['<A-s>'] = {':HopPattern<CR>', 'Hop to pattern'} ['<A-s>'] = {':HopPattern<CR>', 'Hop to pattern'}
}) })
@ -122,16 +116,21 @@ wk.register({
-- Normal mode (with leader key) -- -- Normal mode (with leader key) --
----------------------------------- -----------------------------------
wk.register({ wk.register({
a = {':EasyAlign<CR>', 'Align'},
b = { b = {
name = 'Buffer', name = 'Buffer/Tab',
a = {':EasyAlign<CR>', 'Easy align'},
c = {':ColorizerToggle<CR>', 'Colorizer'}, c = {':ColorizerToggle<CR>', 'Colorizer'},
d = {':bdelete<CR>', 'Close buffer'}, d = {':bdelete<CR>', 'Close buffer'},
j = {':BufferLineCyclePrev<CR>', 'Previous buffer'}, j = {':BufferLineCyclePrev<CR>', 'Previous buffer'},
k = {':BufferLineCycleNext<CR>', 'Next buffer'}, k = {':BufferLineCycleNext<CR>', 'Next buffer'},
n = {':enew<CR>', 'New buffer'}, n = {':enew<CR>', 'New buffer'},
u = {':UndotreeToggle<CR>', 'Undotree'}, u = {':UndotreeToggle<CR>', 'Undotree'},
z = {':ZenMode<CR>', 'Zen mode'} z = {':ZenMode<CR>', 'Zen mode'},
D = {'<Cmd>tabclose<CR>', 'Close tab'},
J = {'<Cmd>tabprev<CR>', 'Previous tab'},
K = {'<Cmd>tabnext<CR>', 'Next tab'},
N = {'<Cmd>tabnew<CR>', 'New tab'}
}, },
d = { d = {
@ -244,7 +243,8 @@ wk.register({
e = {':TroubleToggle lsp_document_diagnostics<CR>', 'Document diagnostics list'}, e = {':TroubleToggle lsp_document_diagnostics<CR>', 'Document diagnostics list'},
w = {':TroubleToggle lsp_workspace_diagnostics<CR>', 'Workspace diagnostics list'}, w = {':TroubleToggle lsp_workspace_diagnostics<CR>', 'Workspace diagnostics list'},
l = {':TroubleToggle loclist<CR>', 'Location list items'}, l = {':TroubleToggle loclist<CR>', 'Location list items'},
q = {':TroubleToggle quickfix<CR>', 'Quickfix list'} q = {':TroubleToggle quickfix<CR>', 'Quickfix list'},
t = {':TroubleToggle<CR>', 'Summary'}
} }
}, },
@ -262,13 +262,26 @@ wk.register({
w = {':lua require("spectre").open_visual({select_word = true})<CR>', 'Find/replace cursorword'}, w = {':lua require("spectre").open_visual({select_word = true})<CR>', 'Find/replace cursorword'},
}, },
-- Tab related -- t = {
t = { -- name = 'Todo',
name = 'Tab', -- f = {':TodoQuickFix<CR>', 'Quick fix'},
c = {'<Cmd>tabclose<CR>', 'Close tab'}, -- l = {':TodoLocList<CR>', 'Loclist'},
j = {'<Cmd>tabprev<CR>', 'Previous tab'}, -- t = {':TodoTrouble<CR>', 'Open in Trouble'},
k = {'<Cmd>tabnext<CR>', 'Next tab'}, -- z = {':TodoTelescope<CR>', 'Open in Telescope'}
n = {'<Cmd>tabnew<CR>', 'New tab'} -- },
y ={
name = 'Figlet',
s = {':.!figlet -f standard<CR>', 'standard'},
l = {':.!figlet -f slant<CR>', 'slant'},
b = {':.!figlet -f banner<CR>', 'banner'},
e = {':.!figlet -f lean<CR>', 'lean'},
p = {':.!figlet -f speed<CR>', 'speed'},
r = {':.!figlet -f roman<CR>', 'roman'},
d = {':.!figlet -f doh<CR>', 'doh'},
w = {':.!figlet -f starwars<CR>', 'starwars'},
m = {':.!figlet -f morse<CR>', 'morse'},
x = {':.!toilet -f term -F border<CR>', 'border'}
} }
}, {prefix = '<leader>'}) }, {prefix = '<leader>'})
@ -276,10 +289,7 @@ wk.register({
-- Visual mode (with leader key) -- -- Visual mode (with leader key) --
----------------------------------- -----------------------------------
wk.register({ wk.register({
b = { a = {':EasyAlign<CR>', 'Range align'},
name = 'Buffer',
a = {':EasyAlign<CR>', 'Range easy align'}
},
d = { d = {
name = 'DAP', name = 'DAP',

View File

@ -200,6 +200,58 @@ function M.trouble_conf()
} }
end 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() function M.outline_conf()
vim.g.symbols_outline = { vim.g.symbols_outline = {
highlight_hovered_item = false, highlight_hovered_item = false,

View File

@ -150,7 +150,7 @@ function M.load_options()
-- Undo file path -- Undo file path
opt.undofile = true opt.undofile = true
opt.undodir = vim.fn.stdpath('cache') .. '/undodir' opt.undodir = vim.fn.stdpath('data') .. '/undodir'
end end
return M return M

View File

@ -119,7 +119,7 @@ return require('packer').startup(
} }
use { use {
'machakann/vim-sandwich', 'machakann/vim-sandwich',
keys = {'sa', 'sd', 'sr'} keys = 's'
} }
use { use {
'phaazon/hop.nvim', 'phaazon/hop.nvim',
@ -177,6 +177,12 @@ return require('packer').startup(
cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'}, cmd = {'Trouble', 'TroubleToggle', 'TroubleRefresh'},
config = lsp.trouble_conf 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 { use {
'simrat39/symbols-outline.nvim', 'simrat39/symbols-outline.nvim',
cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'}, cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'},
@ -392,6 +398,6 @@ return require('packer').startup(
-- use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking -- use {'dstein64/vim-startuptime', cmd = 'StartupTime'} -- Just for benchmarking
-- TODO: dial.nvim, rust-tools.nvim, crates.nvim, go.nvim, clojure-vim/*, -- 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 end
) )