From 16a3109430a140d5f3256c520b122d49873f7a62 Mon Sep 17 00:00:00 2001 From: Belal Elsabbagh Date: Tue, 11 Nov 2025 22:09:44 +0200 Subject: [PATCH] updates --- .config/hypr/hyprland.conf | 5 -- .config/nvim/init.lua | 3 +- .config/nvim/lsp/bashls.lua | 28 ++++++++ .config/nvim/lsp/biome.lua | 71 +++++++++++++++++++ .config/nvim/lsp/emmet-language-server.lua | 21 ++++++ .config/nvim/lsp/luals.lua | 9 +++ .config/nvim/lsp/svelte-language-server.lua | 46 ++++++++++++ .config/nvim/lsp/sveltels.lua | 38 ---------- .config/nvim/lua/plugins/formatter.lua | 2 +- .config/nvim/lua/plugins/lazydev.lua | 10 --- .../nvim/lua/plugins/{git.lua => lazygit.lua} | 0 .config/nvim/lua/plugins/luvit-meta.lua | 1 - 12 files changed, 178 insertions(+), 56 deletions(-) create mode 100644 .config/nvim/lsp/bashls.lua create mode 100644 .config/nvim/lsp/biome.lua create mode 100644 .config/nvim/lsp/emmet-language-server.lua create mode 100644 .config/nvim/lsp/svelte-language-server.lua delete mode 100644 .config/nvim/lsp/sveltels.lua delete mode 100644 .config/nvim/lua/plugins/lazydev.lua rename .config/nvim/lua/plugins/{git.lua => lazygit.lua} (100%) delete mode 100644 .config/nvim/lua/plugins/luvit-meta.lua diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index 443b25d..f224cc9 100755 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -183,11 +183,6 @@ input { } } -# https://wiki.hyprland.org/Configuring/Variables/#gestures -gestures { - workspace_swipe = false -} - # Example per-device config # See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more device { diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 8816d88..4cf2e36 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -145,8 +145,9 @@ vim.lsp.enable { 'pyright', 'ruff', 'julials', - 'sveltels', + 'svelte-language-server', 'rust-analyzer', + 'emmet-language-server', 'tsls', 'yamlls', 'astrols', diff --git a/.config/nvim/lsp/bashls.lua b/.config/nvim/lsp/bashls.lua new file mode 100644 index 0000000..c66fd00 --- /dev/null +++ b/.config/nvim/lsp/bashls.lua @@ -0,0 +1,28 @@ +---@brief +--- +--- https://github.com/bash-lsp/bash-language-server +--- +--- `bash-language-server` can be installed via `npm`: +--- ```sh +--- npm i -g bash-language-server +--- ``` +--- +--- Language server for bash, written using tree sitter in typescript. + +---@type vim.lsp.Config +return { + cmd = { 'bash-language-server', 'start' }, + settings = { + bashIde = { + -- Glob pattern for finding and parsing shell script files in the workspace. + -- Used by the background analysis features across files. + + -- Prevent recursive scanning which will cause issues when opening a file + -- directly in the home directory (e.g. ~/foo.sh). + -- + -- Default upstream pattern is "**/*@(.sh|.inc|.bash|.command)". + globPattern = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)', + }, + }, + filetypes = { 'bash', 'sh' }, +} diff --git a/.config/nvim/lsp/biome.lua b/.config/nvim/lsp/biome.lua new file mode 100644 index 0000000..ec45e41 --- /dev/null +++ b/.config/nvim/lsp/biome.lua @@ -0,0 +1,71 @@ +---@brief +--- https://biomejs.dev +--- +--- Toolchain of the web. [Successor of Rome](https://biomejs.dev/blog/annoucing-biome). +--- +--- ```sh +--- npm install [-g] @biomejs/biome +--- ``` +--- +--- ### Monorepo support +--- +--- `biome` supports monorepos by default. It will automatically find the `biome.json` corresponding to the package you are working on, as described in the [documentation](https://biomejs.dev/guides/big-projects/#monorepo). This works without the need of spawning multiple instances of `biome`, saving memory. + +local util = require 'lspconfig.util' + +---@type vim.lsp.Config +return { + cmd = function(dispatchers, config) + local cmd = 'biome' + local local_cmd = (config or {}).root_dir and config.root_dir .. '/node_modules/.bin/biome' + if local_cmd and vim.fn.executable(local_cmd) == 1 then + cmd = local_cmd + end + return vim.lsp.rpc.start({ cmd, 'lsp-proxy' }, dispatchers) + end, + filetypes = { + 'astro', + 'css', + 'graphql', + 'html', + 'javascript', + 'javascriptreact', + 'json', + 'jsonc', + 'svelte', + 'typescript', + 'typescript.tsx', + 'typescriptreact', + 'vue', + }, + workspace_required = true, + 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' }) + -- We fallback to the current working directory if no project root is found + local project_root = vim.fs.root(bufnr, root_markers) or vim.fn.getcwd() + + -- We know that the buffer is using Biome if it has a config file + -- in its directory tree. + local filename = vim.api.nvim_buf_get_name(bufnr) + local biome_config_files = { 'biome.json', 'biome.jsonc' } + biome_config_files = util.insert_package_json(biome_config_files, 'biome', filename) + local is_buffer_using_biome = vim.fs.find(biome_config_files, { + path = filename, + type = 'file', + limit = 1, + upward = true, + stop = vim.fs.dirname(project_root), + })[1] + if not is_buffer_using_biome then + return + end + + on_dir(project_root) + end, +} diff --git a/.config/nvim/lsp/emmet-language-server.lua b/.config/nvim/lsp/emmet-language-server.lua new file mode 100644 index 0000000..faea2fe --- /dev/null +++ b/.config/nvim/lsp/emmet-language-server.lua @@ -0,0 +1,21 @@ +return { + cmd = { 'emmet-language-server', '--stdio' }, + filetypes = { + 'astro', + 'css', + 'eruby', + 'html', + 'htmlangular', + 'htmldjango', + 'javascriptreact', + 'less', + 'pug', + 'sass', + 'scss', + 'svelte', + 'templ', + 'typescriptreact', + 'vue', + }, + root_markers = { '.git' }, +} diff --git a/.config/nvim/lsp/luals.lua b/.config/nvim/lsp/luals.lua index 42daf97..f0375bf 100644 --- a/.config/nvim/lsp/luals.lua +++ b/.config/nvim/lsp/luals.lua @@ -15,6 +15,15 @@ return { runtime = { version = 'LuaJIT', }, + diagnostics = { + globals = { 'vim' }, -- Add 'vim' to the list of global variables + }, + workspace = { + library = { + vim.env.VIMRUNTIME, -- Include Neovim's runtime files for better completion + -- Add other library paths if needed, e.g., for plugins + }, + }, }, }, } diff --git a/.config/nvim/lsp/svelte-language-server.lua b/.config/nvim/lsp/svelte-language-server.lua new file mode 100644 index 0000000..2e2d5f2 --- /dev/null +++ b/.config/nvim/lsp/svelte-language-server.lua @@ -0,0 +1,46 @@ +---@brief +--- +--- https://github.com/sveltejs/language-tools/tree/master/packages/language-server +--- +--- Note: assuming that [ts_ls](#ts_ls) is setup, full JavaScript/TypeScript support (find references, rename, etc of symbols in Svelte files when working in JS/TS files) requires per-project installation and configuration of [typescript-svelte-plugin](https://github.com/sveltejs/language-tools/tree/master/packages/typescript-plugin#usage). +--- +--- `svelte-language-server` can be installed via `npm`: +--- ```sh +--- npm install -g svelte-language-server +--- ``` + +---@type vim.lsp.Config +return { + cmd = { 'svelteserver', '--stdio' }, + filetypes = { 'svelte' }, + root_dir = function(bufnr, on_dir) + local fname = vim.api.nvim_buf_get_name(bufnr) + -- Svelte LSP only supports file:// schema. https://github.com/sveltejs/language-tools/issues/2777 + if vim.uv.fs_stat(fname) ~= nil then + local root_markers = { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock', 'deno.lock' } + root_markers = vim.fn.has 'nvim-0.11.3' == 1 and { root_markers, { '.git' } } or vim.list_extend(root_markers, { '.git' }) + -- We fallback to the current working directory if no project root is found + local project_root = vim.fs.root(bufnr, root_markers) or vim.fn.getcwd() + on_dir(project_root) + end + end, + on_attach = function(client, bufnr) + -- Workaround to trigger reloading JS/TS files + -- See https://github.com/sveltejs/language-tools/issues/2008 + vim.api.nvim_create_autocmd('BufWritePost', { + pattern = { '*.js', '*.ts' }, + group = vim.api.nvim_create_augroup('lspconfig.svelte', {}), + callback = function(ctx) + -- internal API to sync changes that have not yet been saved to the file system + client:notify('$/onDidChangeTsOrJsFile', { uri = ctx.match }) + end, + }) + vim.api.nvim_buf_create_user_command(bufnr, 'LspMigrateToSvelte5', function() + client:exec_cmd { + title = 'Migrate Component to Svelte 5 Syntax', + command = 'migrate_to_svelte_5', + arguments = { vim.uri_from_bufnr(bufnr) }, + } + end, { desc = 'Migrate Component to Svelte 5 Syntax' }) + end, +} diff --git a/.config/nvim/lsp/sveltels.lua b/.config/nvim/lsp/sveltels.lua deleted file mode 100644 index 2a9b452..0000000 --- a/.config/nvim/lsp/sveltels.lua +++ /dev/null @@ -1,38 +0,0 @@ -local function migrate_to_svelte_5() - local clients = vim.lsp.get_clients { - bufnr = 0, - name = 'svelte', - } - for _, client in ipairs(clients) do - client:exec_cmd { - command = 'migrate_to_svelte_5', - arguments = { vim.uri_from_bufnr(0) }, - } - end -end - -return { - default_config = { - cmd = { 'svelteserver', '--stdio' }, - filetypes = { 'svelte' }, - root_dir = { 'node_modules', '.git', 'package.json' }, - }, - commands = { - MigrateToSvelte5 = { - migrate_to_svelte_5, - description = 'Migrate Component to Svelte 5 Syntax', - }, - }, - docs = { - description = [[ -https://github.com/sveltejs/language-tools/tree/master/packages/language-server - -Note: assuming that [ts_ls](#ts_ls) is setup, full JavaScript/TypeScript support (find references, rename, etc of symbols in Svelte files when working in JS/TS files) requires per-project installation and configuration of [typescript-svelte-plugin](https://github.com/sveltejs/language-tools/tree/master/packages/typescript-plugin#usage). - -`svelte-language-server` can be installed via `npm`: -```sh -npm install -g svelte-language-server -``` -]], - }, -} diff --git a/.config/nvim/lua/plugins/formatter.lua b/.config/nvim/lua/plugins/formatter.lua index 582e25d..3b6d4f4 100644 --- a/.config/nvim/lua/plugins/formatter.lua +++ b/.config/nvim/lua/plugins/formatter.lua @@ -31,7 +31,7 @@ return { rust = { 'rustfmt', lsp_format = 'fallback' }, json = { 'biome', 'prettier', stop_after_first = true }, vue = { 'biome', 'prettier' }, - svelte = { 'biome', 'prettier' }, + svelte = { 'biome', 'prettier', stop_after_first = true }, php = { 'pint', 'intelephense', stop_after_first = true }, }, formatters = { diff --git a/.config/nvim/lua/plugins/lazydev.lua b/.config/nvim/lua/plugins/lazydev.lua deleted file mode 100644 index ea0b33e..0000000 --- a/.config/nvim/lua/plugins/lazydev.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - - { path = 'luvit-meta/library', words = { 'vim%.uv' } }, - }, - }, -} diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/lazygit.lua similarity index 100% rename from .config/nvim/lua/plugins/git.lua rename to .config/nvim/lua/plugins/lazygit.lua diff --git a/.config/nvim/lua/plugins/luvit-meta.lua b/.config/nvim/lua/plugins/luvit-meta.lua deleted file mode 100644 index da6ddc7..0000000 --- a/.config/nvim/lua/plugins/luvit-meta.lua +++ /dev/null @@ -1 +0,0 @@ -return { 'Bilal2453/luvit-meta', lazy = true }