From a69b0e8b90b010eac0c632dc9659fde08116a50b Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 19 Oct 2024 01:08:24 -0400 Subject: [PATCH] feat(nvim): add html server --- common/home/neovim/langs/web.nix | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/common/home/neovim/langs/web.nix b/common/home/neovim/langs/web.nix index 29bae264..ecc71f93 100644 --- a/common/home/neovim/langs/web.nix +++ b/common/home/neovim/langs/web.nix @@ -40,7 +40,7 @@ in vim.api.nvim_create_autocmd('FileType', { pattern = 'html', - command = 'setlocal ts=2 sw=2 expandtab', + command = 'setlocal ts=4 sw=4 expandtab', }); vim.api.nvim_create_autocmd('FileType', { @@ -50,9 +50,10 @@ in local lsp = require('lspconfig'); local tsserver = require('typescript-tools'); + local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); tsserver.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), + capabilities = default_capabilities, handlers = { -- format error code with better error message @@ -64,7 +65,7 @@ in }); lsp.eslint.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), + capabilities = default_capabilities, -- auto-save on_attach = function(client, bufnr) @@ -114,7 +115,7 @@ in }); lsp.cssls.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), + capabilities = default_capabilities, settings = { css = { @@ -128,6 +129,27 @@ in }, }, }); + + local html_caps = default_capabilities; + html_caps.textDocument.completion.completionItem.snippetSupport = true; + + lsp.html.setup({ + capabilities = html_caps, + settings = { + configurationSection = { "html", "css", "javascript" }, + embeddedLanguages = { + css = true, + javascript = true, + }, + provideFormatter = true, + tabSize = 4, + insertSpaces = true, + indentEmptyLines = false, + wrapAttributes = 'auto', + wrapAttributesIndentSize = 4, + endWithNewline = true, + }, + }); ''; plugins = [