From a473fb74120579d7752286a638c23e7e2087a650 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 22 Dec 2024 14:49:17 -0500 Subject: [PATCH] fix(nvim): load web LSPs properly --- .../neovim/langs/web/default.nix | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/homeManagerModules/neovim/langs/web/default.nix b/homeManagerModules/neovim/langs/web/default.nix index efdec8eb..51b0ea88 100644 --- a/homeManagerModules/neovim/langs/web/default.nix +++ b/homeManagerModules/neovim/langs/web/default.nix @@ -20,11 +20,11 @@ in { extraLuaConfig = # lua '' - vim.api.nvim_create_autocmd('FileType', { - pattern = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx', 'css', 'scss' }, + local lsp = require('lspconfig'); + local tsserver = require('typescript-tools'); + local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); - callback = function() - vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]]; + local loadDevShell = function() if (devShells['web'] == nil) then devShells['web'] = 1; @@ -33,6 +33,15 @@ in { vim.cmd[[LspStart]]; end); end + end; + + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx', 'css', 'scss' }, + + callback = function() + vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]]; + + loadDevShell(); end, }); @@ -42,13 +51,7 @@ in { callback = function() vim.cmd[[setlocal ts=4 sw=4 expandtab]]; - if (devShells['web'] == nil) then - devShells['web'] = 1; - - require('nix-develop').nix_develop({'${flakeEnv}#web'}, function() - vim.cmd[[LspStart]]; - end); - end + loadDevShell(); end, }); @@ -57,10 +60,6 @@ in { command = 'setlocal iskeyword+=@-@', }); - local lsp = require('lspconfig'); - local tsserver = require('typescript-tools'); - local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); - tsserver.setup({ capabilities = default_capabilities, autostart = false,