Skip to content

Commit deba3c2

Browse files
authored
feat: Add support for an optional import config path (#41)
1 parent ace7904 commit deba3c2

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

.github/workflows/luarocks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
with:
2828
version: ${{ env.LUAROCKS_VERSION }}
2929
dependencies: |
30-
rocks.nvim >= 1.19.0
30+
rocks.nvim >= 2.42.0

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ auto_install = "prompt" # true | false
9494
disable = [
9595
"lhaskell"
9696
]
97+
config_path = "rocks-treesitter.toml"
9798

9899
[treesitter.parser_map]
99100
# You can add custom filetype to parser mappings.
@@ -118,6 +119,7 @@ vim.g.rocks_nvim = {
118119
parser_map = { },
119120
---@type string[] | fun(lang: string, bufnr: integer):boolean
120121
disable = { }, -- filetypes or a function
122+
config_path = "rocks-treesitter.toml",
121123
},
122124
}
123125
```

doc/rocks-treesitter.nvim.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ configure this plugin.
7979
disable = [
8080
"lhaskell"
8181
]
82+
config_path = "rocks-treesitter.toml"
8283

8384
[treesitter.parser_map]
8485
# You can add custom filetype to parser mappings.
@@ -104,6 +105,7 @@ Or, you add a lua table to your `vim.g.rocks_nvim` setting:
104105
parser_map = { },
105106
---@type string[] | fun(lang: string, bufnr: integer):boolean
106107
disable = { }, -- filetypes or a function
108+
config_path = "rocks-treesitter.toml",
107109
},
108110
}
109111
<

lua/rocks_treesitter/config.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ local config = {
1111
disable = {},
1212
---@type table<string, string>
1313
parser_map = require("rocks_treesitter.ft_parser_map"),
14+
---@type string?
15+
config_path = nil,
1416
}
1517

1618
local api = require("rocks.api")
@@ -32,6 +34,11 @@ local api = require("rocks.api")
3234
--- File types to disable highlighting for (lua + toml config)
3335
--- or a function to conditionally disable highlighting (lua only)
3436
---@field disable? string[] | fun(lang: string, bufnr: integer):boolean
37+
---
38+
--- Specify a config path, relative to the base rocks config file, to
39+
--- install treesitter rocks (ex. "rocks-treesitter.toml"). If not set, they will be added
40+
--- to the base config file
41+
--- @field config_path? string
3542

3643
local toml_config = api.get_rocks_toml()["treesitter"]
3744
---@type RocksTreesitterOpts
@@ -75,5 +82,6 @@ config.disable = type(opts.disable) == "function" and opts.disable
7582
---@diagnostic disable-next-line: assign-type-mismatch
7683
config.auto_install = vim.F.if_nil(opts.auto_install, config.auto_install)
7784
config.parser_map = vim.tbl_extend("force", config.parser_map, opts.parser_map or {})
85+
config.config_path = vim.F.if_nil(opts.config_path)
7886

7987
return config

lua/rocks_treesitter/highlight.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ local function install_latest_version(rocks)
8080
end
8181
)
8282
end
83-
api.install(rocks[1].name, tostring(latest_version or "dev"), try_start_highlight)
83+
api.install(rocks[1].name, tostring(latest_version or "dev"), {
84+
callback = try_start_highlight,
85+
config_path = config.config_path,
86+
})
8487
end
8588

8689
---@param rocks Rock[]

rocks-treesitter.nvim-scm-1.rockspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version = _MODREV .. _SPECREV
55

66
dependencies = {
77
"lua >= 5.1",
8-
"rocks.nvim >= 1.19.0",
8+
"rocks.nvim >= 2.42.0",
99
}
1010

1111
source = {

0 commit comments

Comments
 (0)