Neovim LSP stuff

This commit is contained in:
2025-05-21 19:13:17 +03:00
parent 0f4558597e
commit 43eabcc17e
15 changed files with 237 additions and 252 deletions

View File

@ -0,0 +1,19 @@
vim.lsp.config('harper_ls', {
settings = { -- https://writewithharper.com/docs/integrations/neovim
["harper-ls"] = {
isolateEnglish = true, -- highly experimental
fileDictPath = vim.fn.stdpath("config") .. "/spell/spell/",
userDictPath = vim.fn.stdpath("config") .. "/spell/en.utf-8.add",
codeActions = {
forceStable = true -- preserve the order of actions
},
diagnosticSeverity = "information" -- "hint", "information", "warning", "error"
-- markdown = { ignore_link_title = true }
-- linters = { -- turned off by default
-- spelled_numbers = false, wrong_quotes = false, linking_verbs = false,
-- boring_words = false, use_genitive = false, plural_conjugate = false,
-- no_oxford_comma = false,
-- }
}
},
})

View File

@ -0,0 +1,7 @@
vim.lsp.config('lua_ls', {
settings = {
Lua = {
diagnostics = { globals = { "vim" } }
}
}
})

View File

@ -0,0 +1,42 @@
vim.lsp.config('rust_analyzer', {
settings = {
["rust-analyzer"] = {
cargo = {
allFeatures = true,
loadOutDirsFromCheck = true,
runBuildScripts = true,
},
-- Add clippy lints for Rust.
checkOnSave = true,
check = {
-- allFeatures = true,
command = "clippy",
extraArgs = {
"--",
"--no-deps", -- run Clippy only on the given crate
-- Deny, Warn, Allow, Forbid
"-Wclippy::correctness", -- code that is outright wrong or useless
"-Wclippy::complexity", -- code that does something simple but in a complex way
"-Wclippy::suspicious", -- code that is most likely wrong or useless
"-Wclippy::style", -- code that should be written in a more idiomatic way
"-Wclippy::perf", -- code that can be written to run faster
"-Wclippy::pedantic", -- lints which are rather strict or have occasional false positives
"-Wclippy::nursery", -- new lints that are still under development
"-Wclippy::cargo", -- lints for the cargo manifest
-- Use in production
"-Aclippy::restriction", -- lints which prevent the use of language and library features
-- Other
"-Aclippy::must_use_candidate", -- must_use is rather annoing
},
},
procMacro = {
enable = true,
-- ignored = {
-- ["async-trait"] = { "async_trait" },
-- ["napi-derive"] = { "napi" },
-- ["async-recursion"] = { "async_recursion" },
-- },
},
},
}
})

View File

@ -0,0 +1,14 @@
-- https://myriad-dreamin.github.io/tinymist//frontend/neovim.html
vim.lsp.config('tinymist', {
settings = {
formatterPrintWidth = 100, -- can't stand 120
formatterMode = "typstyle", -- or typstfmt
-- exportPdf = "onDocumentHasTitle", -- default: never
semanticTokens = "enable"
},
single_file_support = true,
-- root_dir = function(_, bufnr)
-- return vim.fs.root(bufnr, { ".git" }) or vim.fn.expand "%:p:h"
-- end,
})

View File

@ -0,0 +1,8 @@
vim.lsp.config('yamlls', {
settings = {
yaml = {
format = { enable = true },
schemaStore = { enable = true },
}
}
})

View File

@ -1,22 +1,22 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" },
"LuaSnip": { "branch": "master", "commit": "c1851d5c519611dfc451b6582961b2602e0af89b" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"cyberdream.nvim": { "branch": "main", "commit": "4aa7c64b0b18a542d6587632efa93c3bea469979" },
"friendly-snippets": { "branch": "main", "commit": "fc8f183479a472df60aa86f00e295462f2308178" },
"gitsigns.nvim": { "branch": "main", "commit": "9cd665f46ab7af2e49d140d328b8e72ea1cf511b" },
"cyberdream.nvim": { "branch": "main", "commit": "8407e80415aebd6b052773d751dda7cd9cfc6835" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"gitsigns.nvim": { "branch": "main", "commit": "39e0d1cd44eafed5f30c372e377ab1cb1781ec9f" },
"harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "d39a75bbce4b8aad5d627191ea915179c77c100f" },
"mason.nvim": { "branch": "main", "commit": "888d6ee499d8089a3a4be4309d239d6be1c1e6c0" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-lspconfig": { "branch": "master", "commit": "2e3f389aa06c7b7c29600ec2e67ee64c332077eb" },
"nvim-treesitter": { "branch": "master", "commit": "3b308861a8d7d7bfbe9be51d52e54dcfd9fe3d38" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ed373482db797bbf71bdff37a15c7555a84dce47" },
"nvim-web-devicons": { "branch": "master", "commit": "50b5b06bff13a9b4eab946de7c7033649a6618a1" },
"onedark.nvim": { "branch": "master", "commit": "0e5512d1bebd1f08954710086f87a5caa173a924" },
"nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" },
"nvim-treesitter": { "branch": "master", "commit": "066fd6505377e3fd4aa219e61ce94c2b8bdb0b79" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "b0debd5c424969b4baeabdc8f54db3036c691732" },
"nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" },
"onedark.nvim": { "branch": "master", "commit": "11de4da47f3e69cb70c3ae9816bd8af166cbe121" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },

View File

@ -1,30 +1,16 @@
local lspconfig = require "lspconfig"
-- local lspconfig = require "lspconfig"
vim.diagnostic.config {
underline = true,
virtual_text = {
spacing = 4,
source = "if_many",
severity = { min = vim.diagnostic.severity.WARN },
},
-- virtual_lines = true,
severity_sort = true,
update_in_insert = false,
signs = { text = { "", "!", "󰙎", "󱠃" } }, -- E, W, I, H
float = { source = "if_many", border = vim.g.border_bleed },
}
lspconfig.util.default_config = vim.tbl_deep_extend("force", lspconfig.util.default_config, {
handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = vim.g.border_bleed, max_width = 80
}),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = vim.g.border_bleed, max_width = 80
})
},
capabilities = pcall(require, "cmp_nvim_lsp") and
package.loaded.cmp_nvim_lsp.default_capabilities() or nil
})
require("lspconfig.ui.windows").default_options.border = vim.g.border -- :LspInfo
-- lspconfig.util.default_config = vim.tbl_deep_extend("force", lspconfig.util.default_config, {
-- handlers = {
-- ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
-- border = vim.g.border_bleed, max_width = 80
-- }),
-- ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
-- border = vim.g.border_bleed, max_width = 80
-- })
-- },
-- capabilities = pcall(require, "cmp_nvim_lsp") and
-- package.loaded.cmp_nvim_lsp.default_capabilities() or nil
-- })
--
-- require("lspconfig.ui.windows").default_options.border = vim.g.border -- :LspInfo

View File

@ -5,63 +5,63 @@ vim.g.maplocalleader = " "
-- vim.g.editorconfig = true
-- behaviour
o.swapfile = false
o.undofile = true
o.undolevels = 10000
o.updatetime = 500 -- save swap, trigger CursorHold
o.timeout = false -- hit <ESC> manually instead
o.timeoutlen = 600 -- ms to wait for a mapping sequence
o.splitbelow = true
o.splitright = true
o.ignorecase = true
o.smartcase = true -- don't ignore case for CAPITALS
o.hlsearch = true -- default
o.incsearch = true -- default
o.confirm = true -- :q when there are changes
o.shortmess = "atTIcCF" -- oO?
o.wildmode = "longest:full,full" -- cmd completion
o.completeopt = "menu,menuone,longest" -- omnifunc completion
o.mouse = "a"
o.spell = false
o.spelllang = "en_us,uk"
o.spelloptions = "camel"
o.fileencodings = "utf-8,cp1251,cp866"
o.swapfile = false
o.undofile = true
o.undolevels = 10000
o.updatetime = 500 -- save swap, trigger CursorHold
o.timeout = false -- hit <ESC> manually instead
o.timeoutlen = 600 -- ms to wait for a mapping sequence
o.splitbelow = true
o.splitright = true
o.ignorecase = true
o.smartcase = true -- don't ignore case for CAPITALS
o.hlsearch = true -- default
o.incsearch = true -- default
o.confirm = true -- :q when there are changes
o.shortmess = "atTIcCF" -- oO?
o.wildmode = "longest:full,full" -- cmd completion
o.completeopt = "menu,menuone,longest" -- omnifunc completion
o.mouse = "a"
o.spell = false
o.spelllang = "en_us,uk"
o.spelloptions = "camel"
o.fileencodings = "utf-8,cp1251,cp866"
--o.clipboard = "unnamed"plus?
o.iskeyword:append "-" -- is part of the word
o.formatoptions:append "n" -- indents for numbered lists
-- movement
o.scrolloff = 7 -- vertical
o.sidescrolloff = 10
o.autoindent = true -- default
o.smartindent = true
o.expandtab = true -- spaces > tabs
o.tabstop = 8 -- to see the Tabs, see also `listchars`
o.softtabstop = 4
o.shiftwidth = 4 -- >> and <<
o.virtualedit = "block" -- move cursor anywhere in visual block mode
o.scrolloff = 7 -- vertical
o.sidescrolloff = 10
o.autoindent = true -- default
o.smartindent = true
o.expandtab = true -- spaces > tabs
o.tabstop = 8 -- to see the Tabs, see also `listchars`
o.softtabstop = 4
o.shiftwidth = 4 -- >> and <<
o.virtualedit = "block" -- move cursor anywhere in visual block mode
-- look
o.cmdheight = 1 -- 0 is experimental
o.rulerformat = ""
o.pumheight = 10 -- lines in cmp menu
o.pumblend = 10 -- cmp menu transparency
o.showmode = true -- in cmdline
o.wrap = false
o.linebreak = true -- when `wrap`, break lines at `breakat`
o.showbreak = "🞄" -- 🞄➣◜◞◟◝╴└╰... at the beginning of wrapped lines
o.breakindent = true -- for wrapped blocks to have indent
o.title = true -- better window title
o.list = true -- show trailing invisible chars
o.listchars = "tab:󰌒 ,trail:·,nbsp:%,leadmultispace: ▏" -- ▎▍
o.colorcolumn = "80,100"
o.cursorline = true
o.laststatus = 0 -- 3 for statusline only on last win; 0 to hide
o.conceallevel = 3 -- hide markup
o.number = true
o.numberwidth = 1 -- minimal possible width
o.rnu = true
o.signcolumn = "number"
o.termguicolors = true -- RGB True color
o.fillchars = {
o.cmdheight = 1 -- 0 is experimental
o.rulerformat = ""
o.pumheight = 10 -- lines in cmp menu
o.pumblend = 10 -- cmp menu transparency
o.showmode = true -- in cmdline
o.wrap = false
o.linebreak = true -- when `wrap`, break lines at `breakat`
o.showbreak = "🞄" -- 🞄➣◜◞◟◝╴└╰... at the beginning of wrapped lines
o.breakindent = true -- for wrapped blocks to have indent
o.title = true -- better window title
o.list = true -- show trailing invisible chars
o.listchars = "tab:󰌒 ,trail:·,nbsp:%,leadmultispace: ▏" -- ▎▍
o.colorcolumn = "80,100"
o.cursorline = true
o.laststatus = 0 -- 3 for statusline only on last win; 0 to hide
o.conceallevel = 3 -- hide markup
o.number = true
o.numberwidth = 1 -- minimal possible width
o.rnu = true
o.signcolumn = "number"
o.termguicolors = true -- RGB True color
o.fillchars = {
fold = " ",
foldopen = "",
foldclose = "",
@ -74,3 +74,17 @@ o.fillchars = {
-- CUSTOM
vim.g.border = "single" -- :h nvim_open_win
vim.g.border_bleed = { "🭽", "", "🭾", "", "🭿", "", "🭼", "" } -- full-bleed
vim.diagnostic.config {
underline = true,
virtual_text = {
spacing = 4,
source = "if_many",
severity = { min = vim.diagnostic.severity.WARN },
},
-- virtual_lines = true,
severity_sort = true,
update_in_insert = false,
signs = { text = { "", "!", "󰙎", "󱠃" } }, -- E, W, I, H
float = { source = "if_many", border = vim.g.border_bleed },
}

View File

@ -1,144 +1,47 @@
local M = {
"williamboman/mason-lspconfig.nvim",
event = "BufReadPre",
return {
"mason-org/mason-lspconfig.nvim",
-- event = "BufReadPre",
event = "User LazyFile",
dependencies = { -- load those first
"mason.nvim",
{
"neovim/nvim-lspconfig",
config = function() require "configs.lspconfig" end
}
}
}
M.opts = {
ensure_installed = {
"lua_ls",
"bashls",
"tinymist",
"rust_analyzer",
"yamlls",
"clangd",
"jdtls",
"hyprls",
-- "sqls",
-- "arduino_language_server",
-- "cmake",
--"csharp_ls", -- piece of 󰱵
-- "hls", -- Haskell
-- "taplo", -- toml
-- "jsonls",
-- "ruff_lsp", -- Python
"mason-org/mason.nvim",
opts = {
ui = {
height = 0.8,
border = vim.g.border,
icons = {
package_pending = "󱦳",
package_installed = "",
package_uninstalled = ""
}
}
}
},
-- {
"neovim/nvim-lspconfig",
-- config = function() require "configs.lspconfig" end
-- }
},
handlers = { -- automatic server setup
function(server_name) -- default handler
package.loaded.lspconfig[server_name].setup {}
end
opts = {
automatic_enable = true,
ensure_installed = {
"lua_ls",
"bashls",
"tinymist",
"rust_analyzer",
"yamlls",
"clangd",
"jdtls",
"hyprls",
-- "sqls",
-- "arduino_language_server",
-- "cmake",
--"csharp_ls", -- piece of 󰱵
-- "hls", -- Haskell
-- "taplo", -- toml
-- "jsonls",
-- "ruff_lsp", -- Python
}
}
}
M.opts.handlers.lua_ls = function()
package.loaded.lspconfig.lua_ls.setup {
settings = {
Lua = {
diagnostics = { globals = { "vim" } }
}
}
}
end
M.opts.handlers.harper_ls = function()
package.loaded.lspconfig.harper_ls.setup {
settings = { -- https://writewithharper.com/docs/integrations/neovim
["harper-ls"] = {
isolateEnglish = true, -- highly experimental
fileDictPath = vim.fn.stdpath("config") .. "/spell/spell/",
userDictPath = vim.fn.stdpath("config") .. "/spell/en.utf-8.add",
codeActions = {
forceStable = true -- preserve the order of actions
},
diagnosticSeverity = "information" -- "hint", "information", "warning", "error"
-- markdown = { ignore_link_title = true }
-- linters = { -- turned off by default
-- spelled_numbers = false, wrong_quotes = false, linking_verbs = false,
-- boring_words = false, use_genitive = false, plural_conjugate = false,
-- no_oxford_comma = false,
-- }
}
},
}
end
-- https://myriad-dreamin.github.io/tinymist//frontend/neovim.html
M.opts.handlers.tinymist = function()
package.loaded.lspconfig.tinymist.setup {
settings = {
formatterPrintWidth = 100, -- can't stand 120
formatterMode = "typstyle", -- or typstfmt
-- exportPdf = "onDocumentHasTitle", -- default: never
semanticTokens = "enable"
},
single_file_support = true,
root_dir = function(_, bufnr)
return vim.fs.root(bufnr, { ".git" }) or vim.fn.expand "%:p:h"
end,
}
end
M.opts.handlers.yamlls = function()
package.loaded.lspconfig.yamlls.setup {
settings = {
yaml = {
format = { enable = true },
schemaStore = { enable = true },
}
}
}
end
M.opts.handlers.rust_analyzer = function() -- TODO
package.loaded.lspconfig.rust_analyzer.setup {
settings = {
["rust-analyzer"] = {
cargo = {
allFeatures = true,
loadOutDirsFromCheck = true,
runBuildScripts = true,
},
-- Add clippy lints for Rust.
checkOnSave = true,
check = {
-- allFeatures = true,
command = "clippy",
extraArgs = {
"--",
"--no-deps", -- run Clippy only on the given crate
-- Deny, Warn, Allow, Forbid
"-Wclippy::correctness", -- code that is outright wrong or useless
"-Wclippy::complexity", -- code that does something simple but in a complex way
"-Wclippy::suspicious", -- code that is most likely wrong or useless
"-Wclippy::style", -- code that should be written in a more idiomatic way
"-Wclippy::perf", -- code that can be written to run faster
"-Wclippy::pedantic", -- lints which are rather strict or have occasional false positives
"-Wclippy::nursery", -- new lints that are still under development
"-Wclippy::cargo", -- lints for the cargo manifest
-- Use in production
"-Aclippy::restriction", -- lints which prevent the use of language and library features
-- Other
"-Aclippy::must_use_candidate", -- must_use is rather annoing
},
},
procMacro = {
enable = true,
-- ignored = {
-- ["async-trait"] = { "async_trait" },
-- ["napi-derive"] = { "napi" },
-- ["async-recursion"] = { "async_recursion" },
-- },
},
},
}
}
end
return M

View File

@ -1,14 +0,0 @@
return {
"williamboman/mason.nvim",
opts = {
ui = {
height = 0.8,
border = vim.g.border,
icons = {
package_pending = "󱦳",
package_installed = "",
package_uninstalled = ""
}
}
}
}

View File

@ -2,5 +2,5 @@ return {
"dstein64/vim-startuptime",
cmd = "StartupTime", -- lazy-load on a command
keys = { { "<Leader>us", "<Cmd>StartupTime<CR>", desc = "StartupTime" } },
init = function() vim.g.startuptime_tries = 25 end
init = function() vim.g.startuptime_tries = 10 end
}