From 79f1a457511017c9ad68e4b0aa206f58b6b3a47f Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Wed, 3 Dec 2025 10:36:10 +0100 Subject: Add wmap syntax parser. Add swift LSP rules. Improve tranquil light colors in neovim. --- config/nvim/lua/lsp.lua | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'config/nvim/lua/lsp.lua') diff --git a/config/nvim/lua/lsp.lua b/config/nvim/lua/lsp.lua index 3482564..2c2cbf2 100644 --- a/config/nvim/lua/lsp.lua +++ b/config/nvim/lua/lsp.lua @@ -1,3 +1,7 @@ +local util = require 'lspconfig.util' + +-- JAVASCRIPT FAMILY ----------------------------------------------------------- + vim.lsp.config('ts_ls', { cmd = { 'typescript-language-server', '--stdio' }, filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' }, @@ -19,6 +23,8 @@ vim.lsp.config('svelte', { }) vim.lsp.enable('svelte') +-- PYTHON ---------------------------------------------------------------------- + vim.lsp.config('pyright', { cmd = { 'pyright-langserver', '--stdio' }, filetypes = { 'python' }, @@ -26,6 +32,8 @@ vim.lsp.config('pyright', { }) vim.lsp.enable('pyright') +-- RUST ------------------------------------------------------------------------ + vim.lsp.config('rust_analyzer', { cmd = { 'rust-analyzer' }, filetypes = { 'rust' }, @@ -55,6 +63,8 @@ vim.lsp.config('rust_analyzer', { }) vim.lsp.enable('rust_analyzer') +-- LUA ------------------------------------------------------------------------- + vim.lsp.config('lua_ls', { cmd = { 'lua-language-server' }, filetypes = { 'lua' }, @@ -62,6 +72,8 @@ vim.lsp.config('lua_ls', { }) vim.lsp.enable('lua_ls') +-- GLEAM------------------------------------------------------------------------ + vim.lsp.config('gleam', { cmd = { 'gleam', 'lsp' }, filetypes = { 'gleam' }, @@ -69,6 +81,41 @@ vim.lsp.config('gleam', { }) vim.lsp.enable('gleam') +-- SWIFT AND THE Cs ------------------------------------------------------------ + +vim.lsp.config('sourcekit', { + cmd = { 'sourcekit-lsp' }, + filetypes = { 'swift', 'objc', 'objcpp', 'c', 'cpp' }, + root_dir = function(bufnr, on_dir) + local filename = vim.api.nvim_buf_get_name(bufnr) + on_dir( + util.root_pattern('buildServer.json', '.bsp')(filename) + or util.root_pattern('*.xcodeproj', '*.xcworkspace')(filename) + -- better to keep it at the end, because some modularized apps contain multiple Package.swift files + or util.root_pattern('compile_commands.json', 'Package.swift')(filename) + or vim.fs.dirname(vim.fs.find('.git', { path = filename, upward = true })[1]) + ) + end, + get_language_id = function(_, ftype) + local t = { objc = 'objective-c', objcpp = 'objective-cpp' } + return t[ftype] or ftype + end, + capabilities = { + workspace = { + didChangeWatchedFiles = { + dynamicRegistration = true, + }, + }, + textDocument = { + diagnostic = { + dynamicRegistration = true, + relatedDocumentSupport = true, + }, + }, + }, +}) +vim.lsp.enable('sourcekit') + -- Enable inlay hints for Rust when LSP attaches vim.api.nvim_create_autocmd('LspAttach', { callback = function(args) -- cgit