Compare commits
1 commit
master
...
treesitter
| Author | SHA1 | Date | |
|---|---|---|---|
| f095d0cbf5 |
4 changed files with 46 additions and 63 deletions
|
|
@ -1,5 +0,0 @@
|
||||||
return {
|
|
||||||
settings = {
|
|
||||||
exportPdf = "onType",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -7,15 +7,14 @@ return {
|
||||||
load = function()
|
load = function()
|
||||||
core.lsp.setup()
|
core.lsp.setup()
|
||||||
require("mason-lspconfig").setup {
|
require("mason-lspconfig").setup {
|
||||||
ensure_installed = {
|
ensure_added = {
|
||||||
"clangd",
|
"clangd",
|
||||||
"mesonlsp",
|
"mesonlsp",
|
||||||
"bashls",
|
"bashls",
|
||||||
"jdtls",
|
"jdtls",
|
||||||
"lua_ls",
|
"lua_ls",
|
||||||
"basedpyright",
|
"basedpyright",
|
||||||
"zls",
|
"debugpy"
|
||||||
"nil_ls"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,59 @@
|
||||||
local map = core.misc.map
|
local map, auto = core.misc.map, core.misc.auto
|
||||||
|
|
||||||
return {
|
local function highlight(buf)
|
||||||
{ "nvim-treesitter/nvim-treesitter",
|
local lang = vim.bo[buf].ft
|
||||||
branch = "master",
|
if table.contains({ "diff", "tex" }, lang) then
|
||||||
config = function()
|
return false
|
||||||
vim.cmd("TSUpdate")
|
|
||||||
end,
|
|
||||||
load = function()
|
|
||||||
require("nvim-treesitter.configs").setup {
|
|
||||||
-- good default parsers
|
|
||||||
ensure_installed = { "c", "lua", "vim", "vimdoc", "markdown",
|
|
||||||
"markdown_inline", "java", "bash", "css", "html", "luadoc",
|
|
||||||
"make", "zig"
|
|
||||||
},
|
|
||||||
|
|
||||||
-- indentation
|
|
||||||
indent = {
|
|
||||||
enable = true,
|
|
||||||
|
|
||||||
disable = function(lang, _)
|
|
||||||
-- disable indenting in php (it's more broken with than without)
|
|
||||||
return table.contains(({
|
|
||||||
"php"
|
|
||||||
}), lang)
|
|
||||||
end
|
|
||||||
},
|
|
||||||
|
|
||||||
-- enable highlighting
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
-- use vim highlighting in addition to treesitter
|
|
||||||
additional_vim_regex_highlighting = true,
|
|
||||||
|
|
||||||
disable = function(lang, buf)
|
|
||||||
-- disable in some files where vim's builtin highlighting is better
|
|
||||||
if table.contains(({
|
|
||||||
"diff", "tex"
|
|
||||||
}), lang) then
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- disable in big files
|
-- disable in big files
|
||||||
local ok, stats = pcall(vim.uv.fs_stat,
|
local ok, stats = pcall(vim.uv.fs_stat,
|
||||||
vim.api.nvim_buf_get_name(buf))
|
vim.api.nvim_buf_get_name(buf))
|
||||||
if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then
|
if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function indent(buf)
|
||||||
|
local lang = vim.bo[buf].ft
|
||||||
|
-- disable indenting in php (it's more broken with than without)
|
||||||
|
return not table.contains({ "php" }, lang)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
{ "nvim-treesitter/nvim-treesitter",
|
||||||
|
branch = "main",
|
||||||
|
config = function()
|
||||||
|
vim.cmd("TSUpdate")
|
||||||
|
end,
|
||||||
|
load = function()
|
||||||
|
local treesitter = require("nvim-treesitter")
|
||||||
|
treesitter.setup {}
|
||||||
|
treesitter.install({
|
||||||
|
"c", "lua", "vim", "vimdoc", "markdown",
|
||||||
|
"markdown_inline", "java", "bash", "css", "html", "luadoc",
|
||||||
|
"make", "zig"
|
||||||
|
}, {
|
||||||
|
force = false,
|
||||||
|
summary = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
auto("FileType", {
|
||||||
|
callback = function(ev)
|
||||||
|
if highlight(ev.buf) then
|
||||||
|
pcall(vim.treesitter.start)
|
||||||
|
vim.bo[ev.buf].syntax = "ON"
|
||||||
end
|
end
|
||||||
|
if indent(ev.buf) then
|
||||||
|
vim.bo[ev.buf].indentexpr = "v:lua.require('nvim-treesitter').indentexpr()"
|
||||||
end
|
end
|
||||||
}
|
end,
|
||||||
}
|
})
|
||||||
|
|
||||||
core.misc.map("n", "<leader><leader>t", function()
|
core.misc.map("n", "<leader><leader>t", function()
|
||||||
pcall(vim.cmd.TSInstall, vim.api.nvim_get_option_value("ft", {
|
treesitter.install { vim.bo[0].ft }
|
||||||
buf = vim.api.nvim_get_current_buf()
|
|
||||||
}))
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
dofile(core.snippets)
|
|
||||||
|
|
||||||
return {
|
|
||||||
s("[]", {
|
|
||||||
t("["),
|
|
||||||
i(1),
|
|
||||||
t("]("),
|
|
||||||
i(2),
|
|
||||||
t(")"),
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue