summaryrefslogtreecommitdiff
path: root/.config/nvim/lsp
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lsp')
-rw-r--r--.config/nvim/lsp/asm_lsp.lua8
-rw-r--r--.config/nvim/lsp/astro.lua20
-rw-r--r--.config/nvim/lsp/basedpyright.lua56
-rw-r--r--.config/nvim/lsp/bashls.lua12
-rw-r--r--.config/nvim/lsp/clangd.lua107
-rw-r--r--.config/nvim/lsp/cssls.lua21
-rw-r--r--.config/nvim/lsp/gopls.lua91
-rw-r--r--.config/nvim/lsp/html.lua16
-rw-r--r--.config/nvim/lsp/jsonls.lua10
-rw-r--r--.config/nvim/lsp/lemminx.lua7
-rw-r--r--.config/nvim/lsp/lua_ls.lua47
-rw-r--r--.config/nvim/lsp/markdown_oxide.lua14
-rw-r--r--.config/nvim/lsp/marksman.lua7
-rw-r--r--.config/nvim/lsp/mdx_analyzer.lua21
-rw-r--r--.config/nvim/lsp/neocmake.lua7
-rw-r--r--.config/nvim/lsp/nil_ls.lua7
-rw-r--r--.config/nvim/lsp/tailwindcss.lua133
-rw-r--r--.config/nvim/lsp/taplo.lua7
-rw-r--r--.config/nvim/lsp/ts_ls.lua47
-rw-r--r--.config/nvim/lsp/yamlls.lua14
-rw-r--r--.config/nvim/lsp/zls.lua24
21 files changed, 676 insertions, 0 deletions
diff --git a/.config/nvim/lsp/asm_lsp.lua b/.config/nvim/lsp/asm_lsp.lua
new file mode 100644
index 0000000..caddea0
--- /dev/null
+++ b/.config/nvim/lsp/asm_lsp.lua
@@ -0,0 +1,8 @@
+-- https://github.com/bergercookie/asm-lsp
+
+return {
+ mason = false,
+ cmd = { 'asm-lsp' },
+ filetypes = { 'asm', 'vmasm' },
+ root_markers = { '.asm-lsp.toml', '.git' },
+}
diff --git a/.config/nvim/lsp/astro.lua b/.config/nvim/lsp/astro.lua
new file mode 100644
index 0000000..2bee9fe
--- /dev/null
+++ b/.config/nvim/lsp/astro.lua
@@ -0,0 +1,20 @@
+-- https://github.com/withastro/language-tools/tree/main/packages/language-server
+
+local function get_typescript_server_path(root_dir)
+ local project_root = vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1])
+ return project_root and vim.fs.joinpath(project_root, 'node_modules', 'typescript', 'lib') or ''
+end
+
+return {
+ cmd = { 'astro-ls', '--stdio' },
+ filetypes = { 'astro' },
+ root_markers = { 'package.json', 'tsconfig.json', 'jsconfig.json', '.git' },
+ init_options = {
+ typescript = {},
+ },
+ before_init = function(_, config)
+ if config.init_options and config.init_options.typescript and not config.init_options.typescript.tsdk then
+ config.init_options.typescript.tsdk = get_typescript_server_path(config.root_dir)
+ end
+ end,
+}
diff --git a/.config/nvim/lsp/basedpyright.lua b/.config/nvim/lsp/basedpyright.lua
new file mode 100644
index 0000000..d076946
--- /dev/null
+++ b/.config/nvim/lsp/basedpyright.lua
@@ -0,0 +1,56 @@
+-- https://detachhead.github.io/basedpyright
+
+local function set_python_path(path)
+ local clients = vim.lsp.get_clients({
+ bufnr = vim.api.nvim_get_current_buf(),
+ name = 'basedpyright',
+ })
+ for _, client in ipairs(clients) do
+ if client.settings then
+ client.settings.python = vim.tbl_deep_extend('force', client.settings.python or {}, { pythonPath = path })
+ else
+ client.config.settings =
+ vim.tbl_deep_extend('force', client.config.settings, { python = { pythonPath = path } })
+ end
+ client.notify('workspace/didChangeConfiguration', { settings = nil })
+ end
+end
+
+return {
+ cmd = { 'basedpyright-langserver', '--stdio' },
+ filetypes = { 'python' },
+ root_markers = {
+ 'pyproject.toml',
+ 'setup.py',
+ 'setup.cfg',
+ 'requirements.txt',
+ 'Pipfile',
+ 'pyrightconfig.json',
+ '.git',
+ },
+ settings = {
+ basedpyright = {
+ analysis = {
+ autoSearchPaths = true,
+ useLibraryCodeForTypes = true,
+ diagnosticMode = 'openFilesOnly',
+ },
+ },
+ },
+ on_attach = function(client, bufnr)
+ vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function()
+ client:exec_cmd({
+ command = 'basedpyright.organizeimports',
+ arguments = { vim.uri_from_bufnr(bufnr) },
+ })
+ end, {
+ desc = 'Organize Imports',
+ })
+
+ vim.api.nvim_buf_create_user_command(0, 'LspPyrightSetPythonPath', set_python_path, {
+ desc = 'Reconfigure basedpyright with the provided python path',
+ nargs = 1,
+ complete = 'file',
+ })
+ end,
+}
diff --git a/.config/nvim/lsp/bashls.lua b/.config/nvim/lsp/bashls.lua
new file mode 100644
index 0000000..16b508d
--- /dev/null
+++ b/.config/nvim/lsp/bashls.lua
@@ -0,0 +1,12 @@
+-- https://github.com/bash-lsp/bash-language-server
+
+return {
+ cmd = { 'bash-language-server', 'start' },
+ filetypes = { 'bash', 'sh', 'zsh' },
+ root_markers = { '.git' },
+ settings = {
+ bashIde = {
+ globPattern = '*@(.sh|.inc|.bash|.command)',
+ },
+ },
+}
diff --git a/.config/nvim/lsp/clangd.lua b/.config/nvim/lsp/clangd.lua
new file mode 100644
index 0000000..01ae2e1
--- /dev/null
+++ b/.config/nvim/lsp/clangd.lua
@@ -0,0 +1,107 @@
+-- https://clangd.llvm.org/installation.html
+---
+--- - **NOTE:** Clang >= 11 is recommended! See [#23](https://github.com/neovim/nvim-lspconfig/issues/23).
+--- - If `compile_commands.json` lives in a build directory, you should
+--- symlink it to the root of your source tree.
+--- ```
+--- ln -s /path/to/myproject/build/compile_commands.json /path/to/myproject/
+--- ```
+--- - clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
+--- specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson
+
+-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
+local function switch_source_header(bufnr)
+ local method_name = 'textDocument/switchSourceHeader'
+ local client = vim.lsp.get_clients({ bufnr = bufnr, name = 'clangd' })[1]
+ if not client then
+ return vim.notify(
+ ('method %s is not supported by any servers active on the current buffer'):format(method_name)
+ )
+ end
+ local params = vim.lsp.util.make_text_document_params(bufnr)
+ client.request(method_name, params, function(err, result)
+ if err then
+ error(tostring(err))
+ end
+ if not result then
+ vim.notify('corresponding file cannot be determined')
+ return
+ end
+ vim.cmd.edit(vim.uri_to_fname(result))
+ end, bufnr)
+end
+
+local function symbol_info()
+ local bufnr = vim.api.nvim_get_current_buf()
+ local clangd_client = vim.lsp.get_clients({ bufnr = bufnr, name = 'clangd' })[1]
+ if not clangd_client or not clangd_client.supports_method('textDocument/symbolInfo') then
+ return vim.notify('Clangd client not found', vim.log.levels.ERROR)
+ end
+ local win = vim.api.nvim_get_current_win()
+ local params = vim.lsp.util.make_position_params(win, clangd_client.offset_encoding)
+ clangd_client.request('textDocument/symbolInfo', params, function(err, res)
+ if err or #res == 0 then
+ -- Clangd always returns an error, there is not reason to parse it
+ return
+ end
+ local container = string.format('container: %s', res[1].containerName) ---@type string
+ local name = string.format('name: %s', res[1].name) ---@type string
+ vim.lsp.util.open_floating_preview({ name, container }, '', {
+ height = 2,
+ width = math.max(string.len(name), string.len(container)),
+ focusable = false,
+ focus = false,
+ border = 'single',
+ title = 'Symbol Info',
+ })
+ end, bufnr)
+end
+
+return {
+ mason = false,
+ cmd = {
+ 'clangd',
+ '--background-index',
+ '--clang-tidy',
+ '--header-insertion=iwyu',
+ '--completion-style=detailed',
+ '--function-arg-placeholders',
+ '--fallback-style=llvm',
+ },
+ filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda', 'proto' },
+ root_markers = {
+ '.clangd',
+ '.clang-tidy',
+ '.clang-format',
+ 'compile_commands.json',
+ 'compile_flags.txt',
+ 'configure.ac', -- AutoTools
+ '.git',
+ },
+ init_options = {
+ usePlaceholders = true,
+ completeUnimported = true,
+ clangdFileStatus = true,
+ },
+ capabilities = {
+ textDocument = {
+ completion = {
+ editsNearCursor = true,
+ },
+ },
+ offsetEncoding = { 'utf-8', 'utf-16' },
+ },
+ on_attach = function()
+ vim.api.nvim_buf_create_user_command(0, 'ClangdSwitchSourceHeader', function()
+ switch_source_header(0)
+ end, { desc = 'Switch between source/header' })
+
+ vim.api.nvim_buf_create_user_command(0, 'ClangdShowSymbolInfo', function()
+ symbol_info()
+ end, { desc = 'Show symbol info' })
+
+ vim.keymap.set('n', 'H', '<cmd>ClangdSwitchSourceHeader<cr>', { desc = '[H]eader and Source Switcher' })
+ vim.keymap.set('n', 'K', '<cmd>lua require("pretty_hover").hover()<cr>', { desc = 'Documentation Hover' })
+ -- TODO: do I need pretty_hover? maybe that's what causes issues?
+ end,
+}
diff --git a/.config/nvim/lsp/cssls.lua b/.config/nvim/lsp/cssls.lua
new file mode 100644
index 0000000..06184c5
--- /dev/null
+++ b/.config/nvim/lsp/cssls.lua
@@ -0,0 +1,21 @@
+-- https://github.com/hrsh7th/vscode-langservers-extracted
+
+return {
+ cmd = { 'vscode-css-language-server', '--stdio' },
+ filetypes = { 'css', 'scss', 'less', 'astro' },
+ init_options = {
+ provideFormatter = true,
+ },
+ root_markers = { 'package.json', '.git' },
+ settings = {
+ css = {
+ validate = true,
+ },
+ less = {
+ validate = true,
+ },
+ scss = {
+ validate = true,
+ },
+ },
+}
diff --git a/.config/nvim/lsp/gopls.lua b/.config/nvim/lsp/gopls.lua
new file mode 100644
index 0000000..3585808
--- /dev/null
+++ b/.config/nvim/lsp/gopls.lua
@@ -0,0 +1,91 @@
+-- https://github.com/golang/tools/tree/master/gopls
+
+local mod_cache = nil
+
+---@param fname string
+---@return string?
+local function get_root(fname)
+ if mod_cache and fname:sub(1, #mod_cache) == mod_cache then
+ local clients = vim.lsp.get_clients({ name = 'gopls' })
+ if #clients > 0 then
+ return clients[#clients].config.root_dir
+ end
+ end
+ return vim.fs.root(fname, { 'go.work', 'go.mod', '.git' })
+end
+
+return {
+ cmd = { 'gopls' },
+ filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' },
+ root_dir = function(bufnr, on_dir)
+ local fname = vim.api.nvim_buf_get_name(bufnr)
+ -- see: https://github.com/neovim/nvim-lspconfig/issues/804
+ if mod_cache then
+ on_dir(get_root(fname))
+ return
+ end
+ local cmd = { 'go', 'env', 'GOMODCACHE' }
+ vim.system(cmd, { text = true }, function(output)
+ if output.code == 0 then
+ if output.stdout then
+ mod_cache = vim.trim(output.stdout)
+ end
+ on_dir(get_root(fname))
+ else
+ vim.notify(('[gopls] cmd failed with code %d: %s\n%s'):format(output.code, cmd, output.stderr))
+ end
+ end)
+ end,
+ settings = {
+ gopls = {
+ gofumpt = true,
+ codelenses = {
+ gc_details = false,
+ generate = true,
+ regenerate_cgo = true,
+ run_govulncheck = true,
+ test = true,
+ tidy = true,
+ upgrade_dependency = true,
+ vendor = true,
+ },
+ hints = {
+ assignVariableTypes = false,
+ compositeLiteralFields = false,
+ compositeLiteralTypes = true,
+ constantValues = true,
+ functionTypeParameters = false,
+ parameterNames = false,
+ rangeVariableTypes = true,
+ },
+ analyses = {
+ fieldalignment = true,
+ nilness = true,
+ unusedparams = true,
+ unusedwrite = true,
+ useany = true,
+ },
+ usePlaceholders = false,
+ completeUnimported = true,
+ staticcheck = true,
+ directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' },
+ semanticTokens = true,
+ },
+ },
+ on_attach = function(client, _)
+ -- workaround for gopls not supporting semanticTokensProvider
+ -- https://github.com/golang/go/issues/54531#issuecomment-1464982242
+ if not client.server_capabilities.semanticTokensProvider then
+ local semantic = client.config.capabilities.textDocument.semanticTokens
+ client.server_capabilities.semanticTokensProvider = {
+ full = true,
+ legend = {
+ tokenTypes = semantic.tokenTypes,
+ tokenModifiers = semantic.tokenModifiers,
+ },
+ range = true,
+ }
+ end
+ -- end workaround
+ end,
+}
diff --git a/.config/nvim/lsp/html.lua b/.config/nvim/lsp/html.lua
new file mode 100644
index 0000000..ced7996
--- /dev/null
+++ b/.config/nvim/lsp/html.lua
@@ -0,0 +1,16 @@
+-- https://github.com/hrsh7th/vscode-langservers-extracted
+
+return {
+ cmd = { 'vscode-html-language-server', '--stdio' },
+ filetypes = { 'html', 'templ' },
+ init_options = {
+ configurationSection = { 'html', 'css', 'javascript' },
+ embeddedLanguages = {
+ css = true,
+ javascript = true,
+ },
+ provideFormatter = true,
+ },
+ root_markers = { 'package.json', '.git' },
+ settings = {},
+}
diff --git a/.config/nvim/lsp/jsonls.lua b/.config/nvim/lsp/jsonls.lua
new file mode 100644
index 0000000..2172d1c
--- /dev/null
+++ b/.config/nvim/lsp/jsonls.lua
@@ -0,0 +1,10 @@
+-- https://github.com/hrsh7th/vscode-langservers-extracted
+
+return {
+ cmd = { 'vscode-json-language-server', '--stdio' },
+ filetypes = { 'json', 'jsonc' },
+ init_options = {
+ provideformatter = true,
+ },
+ root_markers = { '.git' },
+}
diff --git a/.config/nvim/lsp/lemminx.lua b/.config/nvim/lsp/lemminx.lua
new file mode 100644
index 0000000..f58c19a
--- /dev/null
+++ b/.config/nvim/lsp/lemminx.lua
@@ -0,0 +1,7 @@
+-- https://github.com/eclipse/lemminx
+
+return {
+ cmd = { 'lemminx' },
+ filetypes = { 'xml', 'xsd', 'xsl', 'xslt', 'svg' },
+ root_markers = { '.git' },
+}
diff --git a/.config/nvim/lsp/lua_ls.lua b/.config/nvim/lsp/lua_ls.lua
new file mode 100644
index 0000000..fbb4345
--- /dev/null
+++ b/.config/nvim/lsp/lua_ls.lua
@@ -0,0 +1,47 @@
+-- https://github.com/luals/lua-language-server
+
+return {
+ on_init = function(client)
+ if client.workspace_folders then
+ local path = client.workspace_folders[1].name
+ if
+ path ~= vim.fn.stdpath('config')
+ and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc'))
+ then
+ return
+ end
+ end
+
+ client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
+ runtime = {
+ -- Tell the language server which version of Lua you're using
+ -- (most likely LuaJIT in the case of Neovim)
+ version = 'LuaJIT',
+ },
+ -- Make the server aware of Neovim runtime files
+ workspace = {
+ checkThirdParty = false,
+ library = {
+ vim.env.VIMRUNTIME,
+ -- Depending on the usage, you might want to add additional paths here.
+ -- "${3rd}/luv/library"
+ -- "${3rd}/busted/library",
+ },
+ -- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
+ -- library = vim.api.nvim_get_runtime_file("", true)
+ },
+ })
+ end,
+ settings = {
+ Lua = {},
+ diagnostics = { globals = { 'vim' } },
+ telemetry = { enabled = false },
+ hint = { enable = true },
+ workspace = {
+ library = {
+ [vim.fn.expand('$VIMRUNTIME/lua')] = true,
+ [vim.fn.stdpath('config') .. '/lua'] = true,
+ },
+ },
+ },
+}
diff --git a/.config/nvim/lsp/markdown_oxide.lua b/.config/nvim/lsp/markdown_oxide.lua
new file mode 100644
index 0000000..c9e3372
--- /dev/null
+++ b/.config/nvim/lsp/markdown_oxide.lua
@@ -0,0 +1,14 @@
+-- https://github.com/Feel-ix-343/markdown-oxide
+
+return {
+ root_markers = { '.git', '.obsidian', '.moxide.toml' },
+ filetypes = { 'markdown' },
+ cmd = { 'markdown-oxide' },
+ capabilities = {
+ workspace = {
+ didChangeWatchedFiles = {
+ dynamicRegistration = true,
+ },
+ },
+ },
+}
diff --git a/.config/nvim/lsp/marksman.lua b/.config/nvim/lsp/marksman.lua
new file mode 100644
index 0000000..3271cb9
--- /dev/null
+++ b/.config/nvim/lsp/marksman.lua
@@ -0,0 +1,7 @@
+-- https://github.com/artempyanykh/marksman
+
+return {
+ cmd = { 'marksman', 'server' },
+ filetypes = { 'markdown', 'markdown.mdx' },
+ root_markers = { '.marksman.toml', '.git' },
+}
diff --git a/.config/nvim/lsp/mdx_analyzer.lua b/.config/nvim/lsp/mdx_analyzer.lua
new file mode 100644
index 0000000..0f13bc3
--- /dev/null
+++ b/.config/nvim/lsp/mdx_analyzer.lua
@@ -0,0 +1,21 @@
+-- https://github.com/mdx-js/mdx-analyzer
+
+local function get_typescript_server_path(root_dir)
+ local project_root = vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1])
+ return project_root and vim.fs.joinpath(project_root, 'node_modules', 'typescript', 'lib') or ''
+end
+
+return {
+ cmd = { 'mdx-language-server', '--stdio' },
+ filetypes = { 'mdx' },
+ root_markers = { 'package.json' },
+ settings = {},
+ init_options = {
+ typescript = {},
+ },
+ before_init = function(_, config)
+ if config.init_options and config.init_options.typescript and not config.init_options.typescript.tsdk then
+ config.init_options.typescript.tsdk = get_typescript_server_path(config.root_dir)
+ end
+ end,
+}
diff --git a/.config/nvim/lsp/neocmake.lua b/.config/nvim/lsp/neocmake.lua
new file mode 100644
index 0000000..43eae01
--- /dev/null
+++ b/.config/nvim/lsp/neocmake.lua
@@ -0,0 +1,7 @@
+-- https://github.com/Decodetalkers/neocmakelsp
+
+return {
+ cmd = { 'neocmakelsp', '--stdio' },
+ filetypes = { 'cmake' },
+ root_markers = { '.git', 'build', 'cmake' },
+}
diff --git a/.config/nvim/lsp/nil_ls.lua b/.config/nvim/lsp/nil_ls.lua
new file mode 100644
index 0000000..6d711b5
--- /dev/null
+++ b/.config/nvim/lsp/nil_ls.lua
@@ -0,0 +1,7 @@
+-- https://github.com/oxalica/nil
+
+return {
+ cmd = { 'nil' },
+ filetypes = { 'nix' },
+ root_markers = { 'flake.nix', '.git' },
+}
diff --git a/.config/nvim/lsp/tailwindcss.lua b/.config/nvim/lsp/tailwindcss.lua
new file mode 100644
index 0000000..485e44d
--- /dev/null
+++ b/.config/nvim/lsp/tailwindcss.lua
@@ -0,0 +1,133 @@
+-- https://github.com/tailwindlabs/tailwindcss-intellisense
+
+local function insert_package_json(config_files, field, fname)
+ local path = vim.fn.fnamemodify(fname, ':h')
+ local root_with_package = vim.fs.dirname(vim.fs.find('package.json', { path = path, upward = true })[1])
+
+ if root_with_package then
+ -- only add package.json if it contains field parameter
+ local path_sep = '/'
+ for line in io.lines(root_with_package .. path_sep .. 'package.json') do
+ if line:find(field) then
+ config_files[#config_files + 1] = 'package.json'
+ break
+ end
+ end
+ end
+ return config_files
+end
+
+return {
+ cmd = { 'tailwindcss-language-server', '--stdio' },
+ -- filetypes copied and adjusted from tailwindcss-intellisense
+ filetypes = {
+ -- html
+ 'aspnetcorerazor',
+ 'astro',
+ 'astro-markdown',
+ 'blade',
+ 'clojure',
+ 'django-html',
+ 'htmldjango',
+ 'edge',
+ 'eelixir', -- vim ft
+ 'elixir',
+ 'ejs',
+ 'erb',
+ 'eruby', -- vim ft
+ 'gohtml',
+ 'gohtmltmpl',
+ 'haml',
+ 'handlebars',
+ 'hbs',
+ 'html',
+ 'htmlangular',
+ 'html-eex',
+ 'heex',
+ 'jade',
+ 'leaf',
+ 'liquid',
+ 'markdown',
+ 'mdx',
+ 'mustache',
+ 'njk',
+ 'nunjucks',
+ 'php',
+ 'razor',
+ 'slim',
+ 'twig',
+ -- css
+ 'css',
+ 'less',
+ 'postcss',
+ 'sass',
+ 'scss',
+ 'stylus',
+ 'sugarss',
+ -- js
+ 'javascript',
+ 'javascriptreact',
+ 'reason',
+ 'rescript',
+ 'typescript',
+ 'typescriptreact',
+ -- mixed
+ 'vue',
+ 'svelte',
+ 'templ',
+ },
+ settings = {
+ tailwindCSS = {
+ validate = true,
+ lint = {
+ cssConflict = 'warning',
+ invalidApply = 'error',
+ invalidScreen = 'error',
+ invalidVariant = 'error',
+ invalidConfigPath = 'error',
+ invalidTailwindDirective = 'error',
+ recommendedVariantOrder = 'warning',
+ },
+ classAttributes = {
+ 'class',
+ 'className',
+ 'class:list',
+ 'classList',
+ 'ngClass',
+ },
+ includeLanguages = {
+ eelixir = 'html-eex',
+ eruby = 'erb',
+ templ = 'html',
+ htmlangular = 'html',
+ },
+ },
+ },
+ before_init = function(_, config)
+ if not config.settings then
+ config.settings = {}
+ end
+ if not config.settings.editor then
+ config.settings.editor = {}
+ end
+ if not config.settings.editor.tabSize then
+ config.settings.editor.tabSize = vim.lsp.util.get_effective_tabstop()
+ end
+ end,
+ workspace_required = true,
+ root_dir = function(bufnr, on_dir)
+ local root_files = {
+ 'tailwind.config.js',
+ 'tailwind.config.cjs',
+ 'tailwind.config.mjs',
+ 'tailwind.config.ts',
+ 'postcss.config.js',
+ 'postcss.config.cjs',
+ 'postcss.config.mjs',
+ 'postcss.config.ts',
+ }
+ local fname = vim.api.nvim_buf_get_name(bufnr)
+ root_files = insert_package_json(root_files, 'tailwindcss', fname)
+ on_dir(vim.fs.dirname(vim.fs.find(root_files, { path = fname, upward = true })[1]))
+ end,
+}
diff --git a/.config/nvim/lsp/taplo.lua b/.config/nvim/lsp/taplo.lua
new file mode 100644
index 0000000..5bc4832
--- /dev/null
+++ b/.config/nvim/lsp/taplo.lua
@@ -0,0 +1,7 @@
+-- https://taplo.tamasfe.dev/cli/usage/language-server.html
+
+return {
+ cmd = { 'taplo', 'lsp', 'stdio' },
+ filetypes = { 'toml' },
+ root_markers = { '.git' },
+}
diff --git a/.config/nvim/lsp/ts_ls.lua b/.config/nvim/lsp/ts_ls.lua
new file mode 100644
index 0000000..df0ea49
--- /dev/null
+++ b/.config/nvim/lsp/ts_ls.lua
@@ -0,0 +1,47 @@
+-- https://github.com/typescript-language-server/typescript-language-server
+
+--- Use the `:LspTypescriptSourceAction` command to see "whole file" ("source") code-actions such as:
+--- - organize imports
+--- - remove unused code
+
+return {
+ init_options = { hostInfo = 'neovim' },
+ cmd = { 'typescript-language-server', '--stdio' },
+ filetypes = {
+ 'javascript',
+ 'javascriptreact',
+ 'javascript.jsx',
+ 'typescript',
+ 'typescriptreact',
+ 'typescript.tsx',
+ },
+ root_markers = { 'tsconfig.json', 'jsconfig.json', 'package.json', '.git' },
+ handlers = {
+ -- handle rename request for certain code actions like extracting functions / types
+ ['_typescript.rename'] = function(_, result, ctx)
+ local client = assert(vim.lsp.get_client_by_id(ctx.client_id))
+ vim.lsp.util.show_document({
+ uri = result.textDocument.uri,
+ range = {
+ start = result.position,
+ ['end'] = result.position,
+ },
+ }, client.offset_encoding)
+ vim.lsp.buf.rename()
+ return vim.NIL
+ end,
+ },
+ on_attach = function(client)
+ -- ts_ls provides `source.*` code actions that apply to the whole file. These only appear in
+ -- `vim.lsp.buf.code_action()` if specified in `context.only`.
+ vim.api.nvim_buf_create_user_command(0, 'LspTypescriptSourceAction', function()
+ local source_actions = vim.tbl_filter(function(action)
+ return vim.startswith(action, 'source.')
+ end, client.server_capabilities.codeActionProvider.codeActionKinds)
+
+ vim.lsp.buf.code_action({
+ context = { only = source_actions },
+ })
+ end, {})
+ end,
+}
diff --git a/.config/nvim/lsp/yamlls.lua b/.config/nvim/lsp/yamlls.lua
new file mode 100644
index 0000000..b97f463
--- /dev/null
+++ b/.config/nvim/lsp/yamlls.lua
@@ -0,0 +1,14 @@
+-- https://github.com/redhat-developer/yaml-language-server
+
+return {
+ cmd = { 'yaml-language-server', '--stdio' },
+ filetypes = { 'yaml', 'yaml.docker-compose', 'yaml.gitlab' },
+ root_markers = { '.git' },
+ settings = {
+ redhat = {
+ telemetry = {
+ enabled = false,
+ },
+ },
+ },
+}
diff --git a/.config/nvim/lsp/zls.lua b/.config/nvim/lsp/zls.lua
new file mode 100644
index 0000000..32120d3
--- /dev/null
+++ b/.config/nvim/lsp/zls.lua
@@ -0,0 +1,24 @@
+-- https://github.com/zigtools/zls
+
+return {
+ mason = false,
+ cmd = { 'zls' },
+ filetypes = { 'zig', 'zir' },
+ root_markers = { 'zls.json', 'build.zig', '.git' },
+ workspace_required = false,
+ settings = {
+ zls = {
+ enable_build_on_save = true,
+ build_on_save_args = {},
+ enable_argument_placeholders = false,
+ warn_style = true,
+
+ inlay_hints_show_variable_type_hints = true,
+ inlay_hints_show_struct_literal_field_type = true,
+ inlay_hints_show_parameter_name = true,
+ inlay_hints_show_builtin = true,
+ inlay_hints_hide_redundant_param_names = true,
+ inlay_hints_hide_redundant_param_names_last_token = true,
+ },
+ },
+}