|
|
@@ -1,5 +1,3 @@
|
|
|
-local util = require('user.util')
|
|
|
-
|
|
|
vim.diagnostic.config({
|
|
|
-- only show virtual text for WARN and higher
|
|
|
virtual_text = { severity = { min = vim.diagnostic.severity.WARN } },
|
|
|
@@ -11,79 +9,49 @@ vim.lsp.config('*', {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-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 preferences = {
|
|
|
+ importModuleSpecifierPreference = 'non-relative',
|
|
|
+ -- this prevents renames from aliasing when destructuring
|
|
|
+ providePrefixAndSuffixTextForRename = false,
|
|
|
+}
|
|
|
+
|
|
|
+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 },
|
|
|
}
|
|
|
-
|
|
|
- local helix_preferences = vim.tbl_get(
|
|
|
- util.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
|
|
|
|
|
|
-vim.lsp.enable('svelte')
|
|
|
+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
|
|
|
|
|
|
-vim.lsp.enable('gopls')
|
|
|
+ -- 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.config('ruby_lsp', {
|
|
|
init_options = {
|
|
|
@@ -92,7 +60,6 @@ vim.lsp.config('ruby_lsp', {
|
|
|
},
|
|
|
}
|
|
|
})
|
|
|
-vim.lsp.enable('ruby_lsp')
|
|
|
|
|
|
vim.lsp.config('pyright', {
|
|
|
handlers = {
|
|
|
@@ -101,7 +68,6 @@ vim.lsp.config('pyright', {
|
|
|
end
|
|
|
},
|
|
|
})
|
|
|
-vim.lsp.enable('pyright')
|
|
|
|
|
|
vim.lsp.config('nil_ls', {
|
|
|
on_init = function(client)
|
|
|
@@ -111,8 +77,6 @@ vim.lsp.config('nil_ls', {
|
|
|
end,
|
|
|
})
|
|
|
|
|
|
-vim.lsp.enable('nil_ls')
|
|
|
-
|
|
|
vim.lsp.config('jdtls', {
|
|
|
handlers = {
|
|
|
['$/progress'] = function()
|
|
|
@@ -120,9 +84,6 @@ vim.lsp.config('jdtls', {
|
|
|
end
|
|
|
},
|
|
|
})
|
|
|
-vim.lsp.enable('jdtls')
|
|
|
-
|
|
|
-vim.lsp.enable('lua_ls')
|
|
|
|
|
|
-- custom LSP servers
|
|
|
vim.lsp.config('elvish', {
|
|
|
@@ -130,7 +91,6 @@ vim.lsp.config('elvish', {
|
|
|
filetypes = { 'elvish' },
|
|
|
settings = {},
|
|
|
})
|
|
|
-vim.lsp.enable('elvish')
|
|
|
|
|
|
-- diagnostics
|
|
|
vim.keymap.set('n', '<space>e', function() vim.diagnostic.open_float() end)
|
|
|
@@ -215,3 +175,8 @@ vim.api.nvim_create_autocmd('User', {
|
|
|
end,
|
|
|
nested = true,
|
|
|
})
|
|
|
+
|
|
|
+-- only enable LSP servers for shell languages, otherwise they have to be
|
|
|
+-- enabled manually or via .nvim.lua
|
|
|
+vim.lsp.enable('bashls')
|
|
|
+vim.lsp.enable('elvish')
|