summaryrefslogtreecommitdiffstats
path: root/.config/nvim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.config/nvim/init.lua20
-rw-r--r--.config/nvim/lsp/gopls.lua2
-rw-r--r--.config/nvim/lua/lsp.lua29
3 files changed, 33 insertions, 18 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index 597d757..760c009 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -27,14 +27,14 @@ vim.o.mouse = 'a'
vim.o.foldcolumn = "auto"
vim.o.cursorline = true
vim.o.laststatus = 2
-vim.o.statusline = table.concat({
- '%<%n:',
- '%f %h%w%m%r%y ',
- '%=',
- "%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}",
- "%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}",
- "%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}",
- })
+vim.o.statusline = table.concat({
+ '%<%n:',
+ '%f %h%w%m%r%y ',
+ '%=',
+ "%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}",
+ "%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}",
+ "%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}",
+})
vim.o.signcolumn = 'yes'
vim.o.completeopt = "menuone,noselect,popup,fuzzy"
@@ -105,11 +105,9 @@ vim.lsp.enable {
"clangd",
"mesonlsp",
"ts_ls",
- -- "eslint",
"html",
"cssls",
"jsonls",
"ruff",
- "marksman",
- "pyright",
+ "basedpyright",
}
diff --git a/.config/nvim/lsp/gopls.lua b/.config/nvim/lsp/gopls.lua
index 765a0d5..11bf4be 100644
--- a/.config/nvim/lsp/gopls.lua
+++ b/.config/nvim/lsp/gopls.lua
@@ -1,6 +1,8 @@
return {
settings = {
gopls = {
+ staticcheck = true,
+ vulncheck = "Imports",
hints = {
rangeVariableTypes = true,
parameterNames = true,
diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua
index 418179b..144eb6a 100644
--- a/.config/nvim/lua/lsp.lua
+++ b/.config/nvim/lua/lsp.lua
@@ -1,3 +1,5 @@
+local ms = vim.lsp.protocol.Methods
+
---LSP OnAttach
---@param client vim.lsp.Client
---@param buf integer
@@ -15,7 +17,21 @@ function Lsp(client, buf)
vim.keymap.set('n', 'grt', function()
vim.lsp.buf.type_definition()
- end, { desc = 'vim.lsp.buf.type_definition()' })
+ end, { buffer = buf })
+
+ vim.keymap.set({'n', 'v'}, '<leader>f', ":Format<CR>", { buffer = buf })
+
+ vim.api.nvim_buf_create_user_command(buf, "Format", function(args)
+ local range = nil
+ if args.count ~= -1 then
+ local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
+ range = {
+ start = { args.line1, 0 },
+ ["end"] = { args.line2, end_line:len() },
+ }
+ end
+ vim.lsp.buf.format { async = true, range = range, bufnr = buf }
+ end, { range = client:supports_method(ms.textDocument_foldingRange) })
vim.api.nvim_buf_create_user_command(buf, "Symbols", function(args)
if args.args == ""
@@ -26,8 +42,7 @@ function Lsp(client, buf)
end
end, { nargs = "?" })
-
- if client:supports_method('textDocument/inlayHint') then
+ if client:supports_method(ms.textDocument_inlayHint) then
vim.lsp.inlay_hint.enable()
vim.keymap.set('n', '<leader>ih', function()
@@ -35,7 +50,7 @@ function Lsp(client, buf)
end, { buffer = buf })
end
- if client:supports_method('textDocument/completion') then
+ if client:supports_method(ms.textDocument_completion) then
local chars = {}
for i = 32, 126 do
table.insert(chars, string.char(i))
@@ -44,7 +59,7 @@ function Lsp(client, buf)
vim.lsp.completion.enable(true, client.id, buf, { autotrigger = true })
end
- if client:supports_method('textDocument/documentHighlight') then
+ if client:supports_method(ms.textDocument_documentHighlight) then
local highlight_augroup = vim.api.nvim_create_augroup('lsp-highlight',
{ clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
@@ -70,14 +85,14 @@ function Lsp(client, buf)
})
end
- if client:supports_method('textDocument/foldingRange') then
+ if client:supports_method(ms.textDocument_foldingRange) then
local win = vim.api.nvim_get_current_win()
vim.wo[win][0].foldmethod = "expr"
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
end
- if client:supports_method('textDocument/codelens') then
+ if client:supports_method(ms.textDocument_codeLens) then
vim.keymap.set({ 'n', 'v' }, 'grl', function()
vim.lsp.codelens.run()
end, { buffer = buf })