feat(nvim): setup web dev lsps
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-05-09 15:36:57 -04:00
parent c8f8dc98e6
commit 772374b0fd
4 changed files with 51 additions and 7 deletions

View file

@ -16,7 +16,10 @@ in
lib.mkIf neovimIde { lib.mkIf neovimIde {
assertions = [ assertions = [
{ {
assertion = neovimIde && hasPrefix "/home/${mainUser}/" flakeEnv || !neovimIde; assertion =
neovimIde
&& hasPrefix "/home/${mainUser}/" flakeEnv
|| !neovimIde;
message = '' message = ''
Your $FLAKE environment variable needs to point to a directory in Your $FLAKE environment variable needs to point to a directory in
the main users' home to use the neovim module. the main users' home to use the neovim module.

View file

@ -2,6 +2,7 @@
config, config,
pkgs, pkgs,
lib, lib,
stylelint-lsp,
... ...
}: let }: let
inherit (config.vars) neovimIde; inherit (config.vars) neovimIde;
@ -12,10 +13,13 @@ in
neovim = { neovim = {
withNodeJs = true; withNodeJs = true;
extraPackages = with pkgs; [ extraPackages = [
nodejs_latest pkgs.nodejs_latest
nodePackages.npm pkgs.nodePackages.npm
nodePackages.neovim pkgs.nodePackages.neovim
stylelint-lsp.packages.${pkgs.system}.default
pkgs.vscode-langservers-extracted
]; ];
extraLuaConfig = extraLuaConfig =
@ -24,7 +28,7 @@ in
*/ */
'' ''
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = { 'javascript' , 'typescript'}, pattern = { 'javascript', 'typescript', 'css', 'scss' },
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });
@ -35,11 +39,48 @@ in
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = 'scss', pattern = 'scss',
command = 'setl iskeyword+=@-@', command = 'setlocal iskeyword+=@-@',
}); });
local lsp = require('lspconfig');
local coq = require('coq');
local tsserver = require("typescript-tools");
tsserver.setup(coq.lsp_ensure_capabilities({}));
lsp.eslint.setup(coq.lsp_ensure_capabilities({
-- auto-save
on_attach = function(client, bufnr)
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = bufnr,
command = 'EslintFixAll',
});
end,
}));
lsp.cssls.setup(coq.lsp_ensure_capabilities({
settings = {
css = {
validate = false,
},
less = {
validate = false,
},
scss = {
validate = false,
},
},
}));
require('lspconfig').stylelint_lsp.setup(coq.lsp_ensure_capabilities({
settings = {
stylelintplus = {},
},
}));
''; '';
plugins = [ plugins = [
vimPlugins.typescript-tools-nvim
]; ];
}; };
}; };

Binary file not shown.

BIN
flake.nix

Binary file not shown.