add detection of uci files
This commit is contained in:
parent
c32e55d64b
commit
4f33ea54ab
1
init.lua
1
init.lua
@ -17,6 +17,7 @@ require("bindings")
|
|||||||
require("personal.pludin-dev")
|
require("personal.pludin-dev")
|
||||||
require("personal.add-guard")
|
require("personal.add-guard")
|
||||||
require("personal.cmacro-align")
|
require("personal.cmacro-align")
|
||||||
|
require("personal.uci")
|
||||||
|
|
||||||
-- THEME_BEGIN
|
-- THEME_BEGIN
|
||||||
cmd("colorscheme srcery")
|
cmd("colorscheme srcery")
|
||||||
|
31
lua/personal/uci.lua
Normal file
31
lua/personal/uci.lua
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
-- Setup tree sitter
|
||||||
|
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||||
|
parser_config.uci = {
|
||||||
|
install_info = {
|
||||||
|
url = "git@rpuzonas.com:rpuzonas/tree-sitter-uci.git",
|
||||||
|
files = {"src/parser.c"},
|
||||||
|
branch = "main",
|
||||||
|
generate_requires_npm = false,
|
||||||
|
requires_generate_from_grammar = false,
|
||||||
|
},
|
||||||
|
filetype = "uci",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Determine UCI filetype by contents of file.
|
||||||
|
-- If file has no extension and at least one line contains the word "config"
|
||||||
|
vim.filetype.add({
|
||||||
|
pattern = {
|
||||||
|
[".*/etc/config/.*"] = "uci",
|
||||||
|
[".*/[^%.]+"] = {
|
||||||
|
priority = -math.huge,
|
||||||
|
function(_, bufnr)
|
||||||
|
for _, line in ipairs(vim.filetype.getlines(bufnr)) do
|
||||||
|
if line:find("config") ~= nil then
|
||||||
|
return "uci"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -1,8 +1,8 @@
|
|||||||
; This is mandatory to have, If I want "https://git.rpuzonas.com/rpuzonas/tree-sitter-uci" to work :/
|
; This is mandatory to have, If I want "https://git.rpuzonas.com/rpuzonas/tree-sitter-uci" to work :/
|
||||||
"package" @keyword
|
"package" @keyword
|
||||||
"config" @keyword
|
"config" @keyword
|
||||||
"option" @keyword
|
"option" @type
|
||||||
"list" @keyword
|
"list" @type
|
||||||
|
|
||||||
(name) @string
|
(name) @string
|
||||||
(string) @string
|
(string) @string
|
||||||
|
Loading…
Reference in New Issue
Block a user