mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 05:10:44 +00:00
languages/html: add HTML LSP
This commit is contained in:
parent
79447a0024
commit
c4dbf87dee
1 changed files with 45 additions and 3 deletions
|
@ -4,17 +4,54 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.types) bool;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.lists) optional isList;
|
||||
inherit (lib.types) enum either package listOf str bool;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.languages.html;
|
||||
|
||||
defaultServer = "html";
|
||||
servers = {
|
||||
html = {
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
lspConfig = ''
|
||||
lspconfig.html.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/vscode-html-language-server", "--stdio"}''
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.html = {
|
||||
enable = mkEnableOption "HTML language support";
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Enable HTML LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
type = enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
description = "HTML LSP server to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = either package (listOf str);
|
||||
default = pkgs.vscode-langservers-extracted;
|
||||
description = "html-language-server package, or the command to run as a list of strings";
|
||||
};
|
||||
};
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "HTML treesitter support" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkGrammarOption pkgs "html";
|
||||
|
@ -27,6 +64,11 @@ in {
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.html-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim = {
|
||||
startPlugins = optional cfg.treesitter.autotagHtml "nvim-ts-autotag";
|
||||
|
|
Loading…
Reference in a new issue