Sun, 19 Feb 2023 11:29:08 -0600
More option fixes
1015 | 1 | |
2 | local map = vim.keymap | |
3 | local opts = {noremap = true, silent = true} | |
4 | ||
5 | map.set("n", "<F2>", ":20Lexplore<CR>", opts) | |
6 | map.set("n", "<F3>", "n", opts) | |
7 | map.set("n", "<S-F3>", "N", opts) | |
8 | map.set("", "<F4>", ":let v:hlsearch = !v:hlsearch<CR>", opts) | |
1020
b1b644e9825d
Add more plain vim plugins
Meredith Howard <mhoward@roomag.org>
parents:
1017
diff
changeset
|
9 | map.set("n", "<F5>", ":UndotreeToggle<CR>", opts) |
b1b644e9825d
Add more plain vim plugins
Meredith Howard <mhoward@roomag.org>
parents:
1017
diff
changeset
|
10 | map.set("n", "<F8>", ":TagbarToggle<CR>", opts) |
1015 | 11 | |
12 | -- Allow :noh even in insert mode | |
13 | map.set("i", "<F4>", "<C-O><F4>") | |
14 | ||
15 | -- cover for search habit | |
1017 | 16 | map.set("c", "<F3>", "<CR>", opts) |
17 | ||
1022 | 18 | -- change to file's directory |
1017 | 19 | map.set("n", "<leader>cd", ":cd %:p:h<CR>:pwd<CR>", opts) |
1015 | 20 | |
1022 | 21 | -- window switching |
1017 | 22 | map.set("n", "<C-h>", "<C-w>h", opts) |
23 | map.set("n", "<C-j>", "<C-w>j", opts) | |
24 | map.set("n", "<C-k>", "<C-w>k", opts) | |
25 | map.set("n", "<C-l>", "<C-w>l", opts) | |
26 | map.set("n", "<C-\\>", "<C-w>p", opts) | |
1015 | 27 | |
1022 | 28 | -- buffer switching |
1017 | 29 | map.set("n", "gb", "<C-^>", opts) |
30 | map.set("n", "gB", ":ls<CR>:b ", {noremap = true}) | |
1022 | 31 | |
32 | -- Select last paste, in the same mode it was pasted in | |
33 | map.set("n", "gV", "'`[' . strpart(getregtype(), 0, 1) . '`]'", {noremap=true, expr=true}) | |
34 | ||
35 | -- Use ltag over tselect | |
36 | map.set("n", "g<C-]>", ":exe 'ltag ' . expand('<cword>') | lopen<CR>", opts) | |
37 | ||
38 | -- clear all interestingwords with \\k since \K is ri.vim | |
39 | map.set("n", "<leader><leader>k", ":call UncolorAllWords()<CR>", opts) | |
40 | ||
41 | -- mark line | |
42 | map.set("n", "<leader>l", "V<leader>k", opts) | |
43 | ||
44 | -- use Grep for a recursive * | |
45 | map.set("n", "g*", ":Grep<CR>", opts) | |
46 | ||
47 | -- K: doc, gKK: doc current filename | |
48 | map.set("n", "gKK", ":call ViewDoc('doc', expand('%:p'))<CR>", opts) | |
49 | ||
50 | -- Tabular shortcuts | |
51 | map.set("n", "<leader>ta", ":Tabularize first_arrow<CR>", opts) | |
52 | map.set("n", "<leader>te", ":Tabularize first_eq<CR>", opts) | |
53 | map.set("n", "<leader>tc", ":Tabularize first_colon<CR>", opts) | |
54 | map.set("n", "<leader>tm", ":Tabularize methods<CR>", opts) | |
55 | ||
56 | map.set("n", "<leader>a", ":call vimrc#AutoFmtToggle()<CR>", opts) | |
57 | ||
58 | -- LSP features | |
59 | map.set('n', '<leader>d', vim.diagnostic.open_float, opts) | |
60 | map.set('n', '[d', vim.diagnostic.goto_prev, opts) | |
61 | map.set('n', ']d', vim.diagnostic.goto_next, opts) | |
62 | map.set('n', '<leader>ld', vim.diagnostic.setloclist, opts) | |
63 | ||
64 | vim.api.nvim_create_autocmd("LspAttach", { | |
65 | callback = function(args) | |
66 | local bufnr = args.buf | |
67 | local bufopts = { noremap=true, silent=true, buffer=bufnr } | |
68 | ||
69 | map.set('n', 'gD', vim.lsp.buf.declaration, bufopts) | |
70 | map.set('n', 'gd', vim.lsp.buf.definition, bufopts) | |
71 | map.set('n', 'K', vim.lsp.buf.hover, bufopts) | |
72 | map.set('n', 'gi', vim.lsp.buf.implementation, bufopts) | |
73 | map.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) | |
74 | map.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufopts) | |
75 | map.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufopts) | |
76 | map.set('n', '<leader>wl', function() | |
77 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) | |
78 | end, bufopts) | |
79 | map.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts) | |
80 | map.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts) | |
81 | map.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) | |
82 | map.set('n', 'gr', vim.lsp.buf.references, bufopts) | |
83 | map.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, bufopts) | |
84 | end, | |
85 | }) | |
86 |