diff --git a/configuration.nix b/configuration.nix index 98b9999..1817893 100644 --- a/configuration.nix +++ b/configuration.nix @@ -46,6 +46,7 @@ isMaximal: { nix.enable = true; + assembly.enable = isMaximal; markdown.enable = isMaximal; html.enable = isMaximal; css.enable = isMaximal; diff --git a/modules/plugins/languages/asm.nix b/modules/plugins/languages/asm.nix new file mode 100644 index 0000000..b33b330 --- /dev/null +++ b/modules/plugins/languages/asm.nix @@ -0,0 +1,49 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.types) package; + inherit (lib.nvim.types) mkGrammarOption; + + cfg = config.vim.languages.assembly; +in { + options.vim.languages.assembly = { + enable = mkEnableOption "Assembly support"; + + treesitter = { + enable = mkEnableOption "Assembly treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "asm"; + }; + + lsp = { + enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.languages.enableLSP;}; + + package = mkOption { + description = "asm-lsp package"; + type = package; + default = pkgs.asm-lsp; + }; + }; + }; + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.asm-lsp = '' + lspconfig.asm_lsp.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = {"${cfg.lsp.package}/bin/asm-lsp"}, + } + ''; + }) + ]); +} diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 1ec2b68..b3b019b 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -2,6 +2,7 @@ inherit (lib.nvim.languages) mkEnable; in { imports = [ + ./asm.nix ./bash.nix ./dart.nix ./clang.nix