Add hare support

This commit is contained in:
sfigato 2022-10-02 00:46:25 +02:00
parent 5b0e1565ed
commit d35e92f090
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
5 changed files with 56 additions and 1 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "deps/tree-sitter-hare"]
path = deps/tree-sitter-hare
url = https://git.sr.ht/~ecmma/tree-sitter-hare

1
deps/tree-sitter-hare vendored Submodule

@ -0,0 +1 @@
Subproject commit bc26a6a949f2e0d98b7bfc437d459b250900a165

3
filetype.lua Normal file
View File

@ -0,0 +1,3 @@
vim.filetype.add({
extension = { ha = "hare" },
})

View File

@ -1,4 +1,22 @@
local nvim_lsp = require('lspconfig')
local configs = require('lspconfig.configs')
-- harepls
if not configs.harepls then
configs.harepls = {
default_config = {
cmd = { '/home/leo/code/hare/harepls/harepls' };
filetypes = { 'hare' };
root_dir = function(fname)
return nvim_lsp.util.find_git_ancestor(fname)
end;
settings = {};
};
}
end
-- nvim_lsp.harepls.setup {}
local on_attach = function(client, bufrn)
Mapper = require("nvim-mapper")
@ -31,7 +49,19 @@ local on_attach = function(client, bufrn)
end
-- Launch language servers
local servers = { 'pyright', 'pylsp', 'gopls', 'rust_analyzer', 'tsserver', 'elixirls', 'dartls', 'denols', 'clangd', 'zls' }
local servers = {
'harepls',
'pyright',
'pylsp',
'gopls',
'rust_analyzer',
'tsserver',
'elixirls',
'dartls',
'denols',
'clangd',
'zls',
}
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,

View File

@ -23,3 +23,21 @@ require('nvim-treesitter.configs').setup {
enable = true
},
}
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.hare = {
install_info = {
-- url = 'https://git.sr.ht/~ecmma/tree-sitter-hare', -- local path or git repo
url = '/home/leo/.config/nvim/deps/tree-sitter-hare',
files = { "src/parser.c" },
-- optional entries:
-- branch = "main", -- default branch in case of git repo if different from master
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
},
filetype = "ha", -- if filetype does not match the parser name
}
local ft_to_parser = require "nvim-treesitter.parsers".filetype_to_parsername
ft_to_parser.hare = "hare"