add biome and two lsp at once

This commit is contained in:
2026-05-28 02:03:38 +03:00
parent 2c52feaeaa
commit b3fad1fd25
4 changed files with 121 additions and 7 deletions

23
lua/lspconfig/util.lua Normal file
View File

@@ -0,0 +1,23 @@
local M = {}
function M.root_markers_with_field(root_files, new_names, field, fname)
local path = vim.fn.fnamemodify(fname, ':h')
local found = vim.fs.find(new_names, { path = path, upward = true })
for _, f in ipairs(found or {}) do
for line in io.lines(f) do
if line:find(field) then
root_files[#root_files + 1] = vim.fs.basename(f)
break
end
end
end
return root_files
end
function M.insert_package_json(root_files, field, fname)
return M.root_markers_with_field(root_files, { 'package.json', 'package.json5' }, field, fname)
end
return M

View File

@@ -39,14 +39,14 @@ function M.get()
{ ft = 'markdown', ts = { 'markdown', 'markdown_inline' }, format = 'prettier' },
{ ft = 'bash', lsp = 'bash-language-server', lint = 'shellcheck', format = 'shfmt' },
{ ft = 'lua', lsp = 'lua-language-server', lint = 'luacheck', format = 'stylua' },
{ ft = { 'json', 'jsonc' }, lsp = 'json-lsp' },
{ ft = { 'json', 'jsonc' }, lsp = 'biome', format = 'biome' },
{ ft = 'html', lsp = 'html-lsp' },
{ ft = 'css', lsp = { 'css-lsp', 'tailwindcss-language-server' } },
{
ft = { 'javascript', 'typescript', 'javascriptreact', 'typescriptreact' },
ts = { 'javascript', 'typescript', 'tsx' },
lsp = { 'vtsls', 'eslint-lsp' },
format = { 'prettierd', 'prettier' },
lsp = { 'vtsls', 'biome' },
format = 'biome',
},
}
end

View File

@@ -206,13 +206,14 @@ end
-- ======== Cache ========
function M.load_specs()
local specs_raw = require('modules.language-specs').get()
local hash = hash_spec(specs_raw)
local cache = load_cache()
if cache then
if cache and cache.hash == hash then
M.general = cache.spec
else
local specs_raw = require('modules.language-specs').get()
M.general, M.mason = M.generate_specs(specs_raw)
save_cache({ hash = hash_spec(specs_raw), spec = M.general })
save_cache({ hash = hash, spec = M.general })
end
return M.general, M.mason
end
@@ -293,11 +294,19 @@ function M.ts.setup()
end
function M.lsp.setup()
vim.lsp.config('*', {
capabilities = {
general = {
positionEncodings = { 'utf-8' },
},
},
})
for _, lsp_name in ipairs((M.general and M.general.language_servers) or {}) do
vim.lsp.enable(lsp_name)
end
vim.api.nvim_buf_create_user_command(0, 'LspInfo', function()
vim.api.nvim_create_user_command('LspInfo', function()
vim.cmd('checkhealth vim.lsp')
end, {})
end