From ba2022d3c8a3e8a23db3f2c3778e7b9aa51798d6 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 8 Apr 2024 22:13:23 +0100 Subject: [PATCH 1/2] Add builtins highlighting --- queries/highlights.scm | 8 ++++++++ test/highlight/builtins.bp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/highlight/builtins.bp diff --git a/queries/highlights.scm b/queries/highlights.scm index b4cc660..7422e6f 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -49,6 +49,14 @@ field: (identifier) @variable.member)) ; }}} +; Built-ins {{{ +[ + (unset) + "default" +] @variable.builtin +(selection_type) @function.builtin +; }}} + ; Expressions {{{ (map_expression (property diff --git a/test/highlight/builtins.bp b/test/highlight/builtins.bp new file mode 100644 index 0000000..508a8ed --- /dev/null +++ b/test/highlight/builtins.bp @@ -0,0 +1,14 @@ +foo = select(soong_config_variable("my_namespace", "my_var"), { + // ^ function.builtin + "foo": unset, + // ^ variable.builtin + default: select(variant("VARIANT") {}), + // <- variable.builtin + // ^ function.builtin +}) + +/* Assigning to builtins is conveniently not allowed at runtime */ +unset = 12 +// <- variable.builtin +default = 27 +// <- variable.builtin From f5afb4953ff1e9dedf87c253ae9d6f57afc468df Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 9 Apr 2024 17:56:28 +0100 Subject: [PATCH 2/2] WIP --- flake.nix | 18 ++++++++++++++++++ scripts/minimal_init.lua | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 scripts/minimal_init.lua diff --git a/flake.nix b/flake.nix index e7053c4..7449fd2 100644 --- a/flake.nix +++ b/flake.nix @@ -41,11 +41,21 @@ eachDefaultSystem (system: let + inherit (nixpkgs) lib; pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; }; + # FIXME: does it pickup the parser correctly? + nvim-test = pkgs.writeShellScriptBin "nvim-test" '' + export NVIM_PLENARY='${pkgs.vimPlugins.plenary-nvim}' + export NVIM_TREESITTER='${pkgs.vimPlugins.nvim-treesitter}' + + ${pkgs.neovim}/bin/nvim --headless --noplugin -u scripts/minimal_init.lua \ + -c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }" + ''; + bump-version = pkgs.writeShellScriptBin "bump-version" '' set -eu @@ -90,6 +100,13 @@ enable = true; }; + nvim-test = { + enable = true; + name = "nvim tests"; + entry = "${lib.getExe nvim-test}"; + pass_filenames = false; + }; + tree-sitter = { enable = true; name = "tree-sitter tests"; @@ -112,6 +129,7 @@ nativeBuildInputs = with pkgs; [ bump-version nodejs + nvim-test # FIXME: waiting on #301336 # (tree-sitter.override { webUISupport = true; }) tree-sitter diff --git a/scripts/minimal_init.lua b/scripts/minimal_init.lua new file mode 100644 index 0000000..d43d3dc --- /dev/null +++ b/scripts/minimal_init.lua @@ -0,0 +1,19 @@ +vim.opt.runtimepath:append(os.getenv("NVIM_PLENARY")) +vim.opt.runtimepath:append(os.getenv("NVIM_TREESITTER")) + +vim.cmd.runtime({ "plugin/plenary.vim", bang = true }) +vim.cmd.runtime({ "plugin/nvim-treesitter.lua", bang = true }) + +vim.filetype.add({ + extension = { + bp = "bp", + }, +}) + +vim.o.swapfile = false +vim.bo.swapfile = false + +require("nvim-treesitter.configs").setup({ + indent = { enable = true }, + highlight = { enable = true }, +})