From 1604c7423fcc006c1ebe655d7d20cd9fce6b6bbf Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Sat, 9 Nov 2024 21:13:27 +0100 Subject: [PATCH] languages/assembly: init (#447) * asm: init * docs: added changelog for assembly * asm: fixing requested changes * configuration: assembly set to false --- configuration.nix | 2 ++ docs/release-notes/rl-0.7.md | 1 + modules/plugins/languages/asm.nix | 49 +++++++++++++++++++++++++++ modules/plugins/languages/default.nix | 1 + 4 files changed, 53 insertions(+) create mode 100644 modules/plugins/languages/asm.nix diff --git a/configuration.nix b/configuration.nix index 98b99998..cc39d3ff 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 f9eba716..6113cde4 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 00000000..a0e96cef --- /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 1ec2b68f..b3b019bc 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