diff options
| author | David Sadler <david@flashacademy.com> | 2026-07-07 09:15:46 +0100 |
|---|---|---|
| committer | David Sadler <david@flashacademy.com> | 2026-07-07 09:15:46 +0100 |
| commit | 626c119a60701e2908e5795b3941078ebb8dba6b (patch) | |
| tree | ad8b6577953f50ad958051ef1d2493e8785ad4cb /nvim/.config | |
| parent | 4c8d52122d962a0194737450e825471f27c93451 (diff) | |
| parent | fc2b007057dc763de14f9cd7860360bc5c9b646e (diff) | |
Merge branch 'main' into WSL
Diffstat (limited to 'nvim/.config')
| -rw-r--r-- | nvim/.config/nvim/lsp/bash_language_server.lua | 5 | ||||
| -rw-r--r-- | nvim/.config/nvim/lsp/vtsls.lua | 39 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/config/lsp.lua | 2 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/conform.lua | 15 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/nvim-lint.lua | 2 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/nvim-treesitter.lua | 3 |
6 files changed, 66 insertions, 0 deletions
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/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 be37e27..2ddeb6a 100644 --- a/nvim/.config/nvim/lua/config/lsp.lua +++ b/nvim/.config/nvim/lua/config/lsp.lua @@ -1,8 +1,10 @@ vim.lsp.enable({ + "bash_language_server", "intelephense", "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 31d0302..94bdb06 100644 --- a/nvim/.config/nvim/lua/plugins/conform.lua +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -6,10 +6,25 @@ require("conform").setup({ markdown = { "prettier" }, nix = { "nixfmt" }, 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" }, + }, + -- Force shfmt to always use the bash parser variant. + shfmt = { + prepend_args = { "-ln", "bash" }, + }, }, }) 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" }, } 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", }) |
