Compare commits
1 commit
master
...
treesitter
| Author | SHA1 | Date | |
|---|---|---|---|
| f095d0cbf5 |
10 changed files with 127 additions and 87 deletions
|
|
@ -1 +0,0 @@
|
|||
vim.cmd.setlocal("textwidth=80")
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
return {
|
||||
settings = {
|
||||
exportPdf = "onType",
|
||||
}
|
||||
}
|
||||
7
after/lsp/zls.lua
Normal file
7
after/lsp/zls.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
settings = {
|
||||
zls = {
|
||||
enable_build_on_save = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,15 +7,14 @@ return {
|
|||
load = function()
|
||||
core.lsp.setup()
|
||||
require("mason-lspconfig").setup {
|
||||
ensure_installed = {
|
||||
ensure_added = {
|
||||
"clangd",
|
||||
"mesonlsp",
|
||||
"bashls",
|
||||
"jdtls",
|
||||
"lua_ls",
|
||||
"basedpyright",
|
||||
"zls",
|
||||
"nil_ls"
|
||||
"debugpy"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,59 +1,59 @@
|
|||
local map = core.misc.map
|
||||
local map, auto = core.misc.map, core.misc.auto
|
||||
|
||||
return {
|
||||
{ "nvim-treesitter/nvim-treesitter",
|
||||
branch = "master",
|
||||
config = function()
|
||||
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
|
||||
local function highlight(buf)
|
||||
local lang = vim.bo[buf].ft
|
||||
if table.contains({ "diff", "tex" }, lang) then
|
||||
return false
|
||||
end
|
||||
|
||||
-- disable in big files
|
||||
local ok, stats = pcall(vim.uv.fs_stat,
|
||||
vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then
|
||||
return false
|
||||
end
|
||||
|
||||
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
|
||||
if indent(ev.buf) then
|
||||
vim.bo[ev.buf].indentexpr = "v:lua.require('nvim-treesitter').indentexpr()"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
core.misc.map("n", "<leader><leader>t", function()
|
||||
pcall(vim.cmd.TSInstall, vim.api.nvim_get_option_value("ft", {
|
||||
buf = vim.api.nvim_get_current_buf()
|
||||
}))
|
||||
treesitter.install { vim.bo[0].ft }
|
||||
end)
|
||||
end
|
||||
},
|
||||
|
|
|
|||
5
lua/conf/plugins/vimtex.lua
Normal file
5
lua/conf/plugins/vimtex.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
return { "lervag/vimtex",
|
||||
setup = function()
|
||||
vim.g.vimtex_view_method = "zathura"
|
||||
end
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
dofile(core.snippets)
|
||||
|
||||
return {
|
||||
s("[]", {
|
||||
t("["),
|
||||
i(1),
|
||||
t("]("),
|
||||
i(2),
|
||||
t(")"),
|
||||
}),
|
||||
}
|
||||
69
lua/snippets/tex.lua
Normal file
69
lua/snippets/tex.lua
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
dofile(core.snippets)
|
||||
|
||||
return {
|
||||
-- document snippet
|
||||
s("doc",
|
||||
fmta(
|
||||
[[
|
||||
\documentclass{article}
|
||||
\title{<>}
|
||||
\author{<>}
|
||||
\begin{document}
|
||||
\maketitle
|
||||
<>
|
||||
\end{document}
|
||||
]],
|
||||
{
|
||||
c(1, {
|
||||
sn(nil, { f(file_name, {}), i(1) }),
|
||||
i(1, "my title")
|
||||
}),
|
||||
i(2, "my name"),
|
||||
i(0)
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({ trig = ";begin", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}
|
||||
<>
|
||||
\end{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
rep(1)
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({ trig = ";href", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[\href{<>}{<>}]],
|
||||
{
|
||||
i(1, "url"),
|
||||
i(2, "display name"),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
postfix(".b", {
|
||||
f(function(_, parent)
|
||||
return [[\textbf{]]..parent.snippet.env.POSTFIX_MATCH.."}"
|
||||
end)
|
||||
}),
|
||||
|
||||
postfix(".i", {
|
||||
f(function(_, parent)
|
||||
return [[\textit{]]..parent.snippet.env.POSTFIX_MATCH.."}"
|
||||
end)
|
||||
}),
|
||||
|
||||
postfix(".ul", {
|
||||
f(function(_, parent)
|
||||
return [[\underline{]]..parent.snippet.env.POSTFIX_MATCH.."}"
|
||||
end)
|
||||
})
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
dofile(core.snippets)
|
||||
|
||||
return {
|
||||
s("title", {
|
||||
t("#set document(title: ["),
|
||||
i(1, "theTitle"),
|
||||
t({ "])", "#title()" }),
|
||||
})
|
||||
}
|
||||
|
|
@ -7,18 +7,4 @@ return {
|
|||
f(file_name, {}),
|
||||
t(" = @This();"),
|
||||
}),
|
||||
|
||||
s("init", {
|
||||
t("pub fn init() !*"),
|
||||
f(file_name, {}),
|
||||
t({ " {", "\tconst self = try gpa.create(" }),
|
||||
f(file_name, {}),
|
||||
t({ ");", "\tself.* = .{};", "\treturn self;", "}" }),
|
||||
}),
|
||||
|
||||
s("deinit", {
|
||||
t("pub fn deinit(self: *"),
|
||||
f(file_name, {}),
|
||||
t({ ") void {", "\tgpa.destroy(self);", "}" }),
|
||||
}),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue