diff --git a/configuration.nix b/configuration.nix index 98b9999..cc39d3f 100644 --- a/configuration.nix +++ b/configuration.nix @@ -46,6 +46,8 @@ isMaximal: { nix.enable = true; + # Assembly is not common, and the asm LSP is a major hit-or-miss + assembly.enable = false; markdown.enable = isMaximal; html.enable = isMaximal; css.enable = isMaximal; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index f9eba71..6113cde 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -307,6 +307,7 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to - Add LSP, formatter and Treesitter support for Vala under `vim.languages.vala` - Add [Tinymist](https://github.com/Myriad-Dreamin/tinymist] as a formatter for the Typst language module. +- Add LSP and Treesitter support for Assembly under `vim.languages.assembly` [Bloxx12](https://github.com/Bloxx12) diff --git a/modules/plugins/languages/asm.nix b/modules/plugins/languages/asm.nix new file mode 100644 index 0000000..a0e96ce --- /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 { + type = package; + default = pkgs.asm-lsp; + description = "asm-lsp package"; + }; + }; + }; + 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