vim.diagnostic.config({ -- only show virtual text for WARN and higher virtual_text = { severity = { min = vim.diagnostic.severity.WARN } }, }) vim.lsp.config('*', { flags = { debounce_text_changes = 250, } }) local function read_helix_config() local tinytoml = require('tinytoml') local data = vim.secure.read('.helix/languages.toml') if data ~= nil then local status, data = pcall(tinytoml.parse, data, { load_from_string = true }) if status then return data end end return {} end vim.lsp.enable('bashls'); vim.lsp.enable('eslint'); if vim.fn.executable('dprint') == 1 then local version = vim.version.parse(vim.fn.system('dprint --version')) if vim.version.cmp(version, { 0, 45, 0 }) >= 0 then vim.lsp.enable('dprint') end end if vim.fn.executable('deno') == 1 then vim.lsp.enable('deno'); else local preferences = { importModuleSpecifierPreference = 'non-relative', -- this prevents renames from aliasing when destructuring providePrefixAndSuffixTextForRename = false, } local helix_preferences = vim.tbl_get(read_helix_config(), 'language-server', 'typescript-language-server', 'config', 'preferences') if helix_preferences ~= nil then preferences = vim.tbl_deep_extend('force', preferences, helix_preferences) end local function make_settings() -- we disable formatting but these are still used when performing some code -- actions local format = { indentSize = vim.bo.shiftwidth, convertTabsToSpaces = vim.o.expandtab, } return { javascript = { format = format }, typescript = { format = format }, } end vim.lsp.config('ts_ls', { init_options = { completionDisableFilterText = true, preferences = preferences, }, settings = make_settings(), handlers = { ['$/typescriptVersion'] = function(err, result, ctx, config) vim.notify(string.format('Typescript %s', result.version)) end, }, on_init = function(client) -- mark tsserver as not having formatting available as we rely on -- eslint and dprint for that client.server_capabilities.documentFormattingProvider = false client.server_capabilities.documentRangeFormattingProvider = false -- we only really know our settings once we've opened a file so report -- the new formatting settings client:notify(vim.lsp.protocol.Methods.workspace_didChangeConfiguration, { settings = make_settings(), }) end, }) vim.lsp.enable('ts_ls') end if vim.fn.executable('gopls') == 1 then vim.lsp.enable('gopls') end if vim.fn.executable('ruby-lsp') == 1 then vim.lsp.config('ruby_lsp', { init_options = { enabledFeatures = { formatting = false, }, } }) vim.lsp.enable('ruby_lsp') end if vim.fn.executable('nil') == 1 then vim.lsp.enable('nil_ls') end if vim.fn.executable('jdtls') == 1 then vim.lsp.config('jdtls', { handlers = { ['$/progress'] = function() -- this is quite noisy so just disable it end }, }) vim.lsp.enable('jdtls') end vim.lsp.enable('lua_ls') -- custom LSP servers vim.lsp.config('elvish', { cmd = { 'elvish', '--lsp' }, filetypes = { 'elvish' }, settings = {}, }) vim.lsp.enable('elvish')