67 map("n", "<leader>tm", ":Tabularize methods<CR>") |
67 map("n", "<leader>tm", ":Tabularize methods<CR>") |
68 |
68 |
69 map("n", "<leader>a", ":call vimrc#AutoFmtToggle()<CR>") |
69 map("n", "<leader>a", ":call vimrc#AutoFmtToggle()<CR>") |
70 |
70 |
71 -- LSP features |
71 -- LSP features |
72 map("n", "<leader>d", vim.diagnostic.open_float) |
|
73 map("n", "[d", vim.diagnostic.goto_prev) |
|
74 map("n", "]d", vim.diagnostic.goto_next) |
|
75 map("n", "<leader>ld", vim.diagnostic.setloclist) |
|
76 |
|
77 vim.api.nvim_create_augroup("lsp_attach", {}) |
|
78 |
72 |
79 vim.api.nvim_create_autocmd("LspAttach", { |
73 vim.api.nvim_create_autocmd("LspAttach", { |
80 group = "lsp_attach", |
74 group = vim.api.nvim_create_augroup("lsp_attach", { clear = true }), |
81 callback = function(args) |
75 callback = function(args) |
82 local bufnr = args.buf |
76 local bufopts = { buffer = args.buf } |
83 local bufopts = { buffer = bufnr } |
77 |
|
78 map("n", "<leader>d", vim.diagnostic.open_float, bufopts) |
|
79 map("n", "[d", vim.diagnostic.goto_prev, bufopts) |
|
80 map("n", "]d", vim.diagnostic.goto_next, bufopts) |
|
81 map("n", "<leader>ld", vim.diagnostic.setqflist, bufopts) |
84 |
82 |
85 map("n", "gD", vim.lsp.buf.declaration, bufopts) |
83 map("n", "gD", vim.lsp.buf.declaration, bufopts) |
86 map("n", "gd", vim.lsp.buf.definition, bufopts) |
84 map("n", "gd", vim.lsp.buf.definition, bufopts) |
87 map("n", "K", vim.lsp.buf.hover, bufopts) |
85 map("n", "K", vim.lsp.buf.hover, bufopts) |
88 map("n", "gi", vim.lsp.buf.implementation, bufopts) |
86 map("n", "gi", vim.lsp.buf.implementation, bufopts) |
94 end, bufopts) |
92 end, bufopts) |
95 map("n", "<leader>D", vim.lsp.buf.type_definition, bufopts) |
93 map("n", "<leader>D", vim.lsp.buf.type_definition, bufopts) |
96 map("n", "<leader>rn", vim.lsp.buf.rename, bufopts) |
94 map("n", "<leader>rn", vim.lsp.buf.rename, bufopts) |
97 map("n", "<leader>ca", vim.lsp.buf.code_action, bufopts) |
95 map("n", "<leader>ca", vim.lsp.buf.code_action, bufopts) |
98 map("n", "gr", vim.lsp.buf.references, bufopts) |
96 map("n", "gr", vim.lsp.buf.references, bufopts) |
99 map("n", "<leader>f", function() |
97 map({ "n", "x" }, "<leader>f", function() |
100 vim.lsp.buf.format({ async = true }) |
98 vim.lsp.buf.format({ async = true }) |
101 end, bufopts) |
99 end, bufopts) |
102 end, |
100 end, |
103 }) |
101 }) |