mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
ref(nvim): reformat using the all mighty lsp ✨
This commit is contained in:
parent
88a5ea7267
commit
bc9b520671
12 changed files with 147 additions and 152 deletions
|
|
@ -1,5 +1,5 @@
|
|||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap=true, silent=true }
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
|
|
@ -9,7 +9,7 @@ local on_attach = function(_, bufnr)
|
|||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
|
|
@ -26,21 +26,28 @@ local on_attach = function(_, bufnr)
|
|||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, { desc = 'Format current buffer with LSP' })
|
||||
-- vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
-- vim.lsp.buf.format()
|
||||
-- end, { desc = 'Format current buffer with LSP' })
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
require("lspconfig")["lua_ls"].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
lua = {
|
||||
formatting = {
|
||||
enable = true,
|
||||
indent = 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require("lspconfig")["rust_analyzer"].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue