From f51a0faed7bd2881de3c361c852234f3365efcf0 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Thu, 2 Apr 2026 14:38:40 +0100 Subject: Add lsp, formatter, linter for Bash --- nvim/.config/nvim/lsp/bash_language_server.lua | 5 +++++ nvim/.config/nvim/lua/config/lsp.lua | 1 + nvim/.config/nvim/lua/plugins/conform.lua | 2 ++ nvim/.config/nvim/lua/plugins/nvim-lint.lua | 2 ++ 4 files changed, 10 insertions(+) create mode 100644 nvim/.config/nvim/lsp/bash_language_server.lua (limited to 'nvim/.config') diff --git a/nvim/.config/nvim/lsp/bash_language_server.lua b/nvim/.config/nvim/lsp/bash_language_server.lua new file mode 100644 index 0000000..d7c9ef1 --- /dev/null +++ b/nvim/.config/nvim/lsp/bash_language_server.lua @@ -0,0 +1,5 @@ +---@type vim.lsp.Config +return { + cmd = { "bash-language-server", "start" }, + filetypes = { "bash", "sh" }, +} diff --git a/nvim/.config/nvim/lua/config/lsp.lua b/nvim/.config/nvim/lua/config/lsp.lua index be37e27..038ba44 100644 --- a/nvim/.config/nvim/lua/config/lsp.lua +++ b/nvim/.config/nvim/lua/config/lsp.lua @@ -1,4 +1,5 @@ vim.lsp.enable({ + "bash_language_server", "intelephense", "lua_ls", "marksman", diff --git a/nvim/.config/nvim/lua/plugins/conform.lua b/nvim/.config/nvim/lua/plugins/conform.lua index 31d0302..bf6ff47 100644 --- a/nvim/.config/nvim/lua/plugins/conform.lua +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -6,6 +6,8 @@ require("conform").setup({ markdown = { "prettier" }, nix = { "nixfmt" }, php = { "php_cs_fixer" }, + bash = { "shfmt" }, + sh = { "shfmt" }, }, formatters = { php_cs_fixer = { diff --git a/nvim/.config/nvim/lua/plugins/nvim-lint.lua b/nvim/.config/nvim/lua/plugins/nvim-lint.lua index 7129dab..9df79bf 100644 --- a/nvim/.config/nvim/lua/plugins/nvim-lint.lua +++ b/nvim/.config/nvim/lua/plugins/nvim-lint.lua @@ -5,4 +5,6 @@ require("lint").linters_by_ft = { markdown = { "markdownlint-cli2" }, nix = { "statix" }, php = { "phpcs" }, + bash = { "shellcheck" }, + sh = { "shellcheck" }, } -- cgit v1.2.3-13-gbd6f From df06efee9eac3c9a40b3f820956ec3d6edbbe3a7 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Fri, 17 Apr 2026 14:54:23 +0100 Subject: Add lsp, formatter, linter for typescript --- nvim/.config/nvim/lsp/vtsls.lua | 39 +++++++++++++++++++++++ nvim/.config/nvim/lua/config/lsp.lua | 1 + nvim/.config/nvim/lua/plugins/conform.lua | 9 ++++++ nvim/.config/nvim/lua/plugins/nvim-treesitter.lua | 3 ++ 4 files changed, 52 insertions(+) create mode 100644 nvim/.config/nvim/lsp/vtsls.lua (limited to 'nvim/.config') diff --git a/nvim/.config/nvim/lsp/vtsls.lua b/nvim/.config/nvim/lsp/vtsls.lua new file mode 100644 index 0000000..544f942 --- /dev/null +++ b/nvim/.config/nvim/lsp/vtsls.lua @@ -0,0 +1,39 @@ +-- https://raw.githubusercontent.com/neovim/nvim-lspconfig/refs/heads/master/lsp/vtsls.lua +---@type vim.lsp.Config +return { + cmd = { 'vtsls', '--stdio' }, + init_options = { + hostInfo = 'neovim', + }, + filetypes = { + 'javascript', + 'javascriptreact', + 'typescript', + 'typescriptreact', + }, + root_dir = function(bufnr, on_dir) + -- The project root is where the LSP can be started from + -- As stated in the documentation above, this LSP supports monorepos and simple projects. + -- We select then from the project root, which is identified by the presence of a package + -- manager lock file. + local root_markers = { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' } + -- Give the root markers equal priority by wrapping them in a table + root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers, { '.git' } } + or vim.list_extend(root_markers, { '.git' }) + -- exclude deno + local deno_root = vim.fs.root(bufnr, { 'deno.json', 'deno.jsonc' }) + local deno_lock_root = vim.fs.root(bufnr, { 'deno.lock' }) + local project_root = vim.fs.root(bufnr, root_markers) + if deno_lock_root and (not project_root or #deno_lock_root > #project_root) then + -- deno lock is closer than package manager lock, abort + return + end + if deno_root and (not project_root or #deno_root >= #project_root) then + -- deno config is closer than or equal to package manager lock, abort + return + end + -- project is standard TS, not deno + -- We fallback to the current working directory if no project root is found + on_dir(project_root or vim.fn.getcwd()) + end, +} diff --git a/nvim/.config/nvim/lua/config/lsp.lua b/nvim/.config/nvim/lua/config/lsp.lua index 038ba44..2ddeb6a 100644 --- a/nvim/.config/nvim/lua/config/lsp.lua +++ b/nvim/.config/nvim/lua/config/lsp.lua @@ -4,6 +4,7 @@ vim.lsp.enable({ "lua_ls", "marksman", "nixd", + "vtsls", }) vim.diagnostic.config({ diff --git a/nvim/.config/nvim/lua/plugins/conform.lua b/nvim/.config/nvim/lua/plugins/conform.lua index bf6ff47..365fb2d 100644 --- a/nvim/.config/nvim/lua/plugins/conform.lua +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -8,10 +8,19 @@ require("conform").setup({ php = { "php_cs_fixer" }, bash = { "shfmt" }, sh = { "shfmt" }, + javascript = { "biome", "prettier", stop_after_first = true }, + typescript = { "biome", "prettier", stop_after_first = true }, + javascriptreact = { "biome", "prettier", stop_after_first = true }, + typescriptreact = { "biome", "prettier", stop_after_first = true }, }, formatters = { php_cs_fixer = { command = "php-cs-fixer", }, + -- Biome is great because it doesn't require a node_modules folder to work. + biome = { + command = "biome", + args = { "format", "--stdin-file-path", "$FILENAME" }, + }, }, }) diff --git a/nvim/.config/nvim/lua/plugins/nvim-treesitter.lua b/nvim/.config/nvim/lua/plugins/nvim-treesitter.lua index acb3fbd..e646c1b 100644 --- a/nvim/.config/nvim/lua/plugins/nvim-treesitter.lua +++ b/nvim/.config/nvim/lua/plugins/nvim-treesitter.lua @@ -7,10 +7,13 @@ require("nvim-treesitter").install({ "gitattributes", "gitcommit", "gitignore", + "javascript", "json", "lua", "markdown", "markdown_inline", "nix", "php", + "tsx", + "typescript", }) -- cgit v1.2.3-13-gbd6f From 796e8cd52879f87220e76d71d512f2cc6a79a715 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Tue, 30 Jun 2026 21:52:14 +0100 Subject: Fix issue with bash formatting treat scripts as sh instead of bash --- nvim/.config/nvim/lua/plugins/conform.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'nvim/.config') diff --git a/nvim/.config/nvim/lua/plugins/conform.lua b/nvim/.config/nvim/lua/plugins/conform.lua index 365fb2d..94bdb06 100644 --- a/nvim/.config/nvim/lua/plugins/conform.lua +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -22,5 +22,9 @@ require("conform").setup({ command = "biome", args = { "format", "--stdin-file-path", "$FILENAME" }, }, + -- Force shfmt to always use the bash parser variant. + shfmt = { + prepend_args = { "-ln", "bash" }, + }, }, }) -- cgit v1.2.3-13-gbd6f