summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nvim/.config/nvim/lsp/vtsls.lua39
-rw-r--r--nvim/.config/nvim/lua/config/lsp.lua1
-rw-r--r--nvim/.config/nvim/lua/plugins/conform.lua9
-rw-r--r--nvim/.config/nvim/lua/plugins/nvim-treesitter.lua3
4 files changed, 52 insertions, 0 deletions
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",
})