diff --git a/after/ftplugin/typst.lua b/after/ftplugin/typst.lua deleted file mode 100644 index c642643..0000000 --- a/after/ftplugin/typst.lua +++ /dev/null @@ -1 +0,0 @@ -vim.cmd.setlocal("textwidth=80") diff --git a/after/lsp/tinymist.lua b/after/lsp/tinymist.lua deleted file mode 100644 index 6220be5..0000000 --- a/after/lsp/tinymist.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - settings = { - exportPdf = "onType", - } -} diff --git a/after/lsp/zls.lua b/after/lsp/zls.lua new file mode 100644 index 0000000..9dc490e --- /dev/null +++ b/after/lsp/zls.lua @@ -0,0 +1,7 @@ +return { + settings = { + zls = { + enable_build_on_save = true + } + } +} diff --git a/lua/conf/plugins/lsp.lua b/lua/conf/plugins/lsp.lua index 0d9f4c0..128d1f1 100644 --- a/lua/conf/plugins/lsp.lua +++ b/lua/conf/plugins/lsp.lua @@ -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 diff --git a/lua/conf/plugins/treesitter.lua b/lua/conf/plugins/treesitter.lua index 30d31a5..17588f6 100644 --- a/lua/conf/plugins/treesitter.lua +++ b/lua/conf/plugins/treesitter.lua @@ -1,59 +1,59 @@ -local map = core.misc.map +local map, auto = core.misc.map, core.misc.auto + +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 = "master", + branch = "main", 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" - }, + 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, + }) - -- indentation - indent = { - enable = true, - - disable = function(lang, _) - -- disable indenting in php (it's more broken with than without) - return table.contains(({ - "php" - }), lang) + auto("FileType", { + callback = function(ev) + if highlight(ev.buf) then + pcall(vim.treesitter.start) + vim.bo[ev.buf].syntax = "ON" 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 - - -- 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 true - end + if indent(ev.buf) then + vim.bo[ev.buf].indentexpr = "v:lua.require('nvim-treesitter').indentexpr()" end - } - } + end, + }) core.misc.map("n", "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 }, diff --git a/lua/conf/plugins/vimtex.lua b/lua/conf/plugins/vimtex.lua new file mode 100644 index 0000000..660efda --- /dev/null +++ b/lua/conf/plugins/vimtex.lua @@ -0,0 +1,5 @@ +return { "lervag/vimtex", + setup = function() + vim.g.vimtex_view_method = "zathura" + end +} diff --git a/lua/snippets/markdown.lua b/lua/snippets/markdown.lua deleted file mode 100644 index 77edb4a..0000000 --- a/lua/snippets/markdown.lua +++ /dev/null @@ -1,11 +0,0 @@ -dofile(core.snippets) - -return { - s("[]", { - t("["), - i(1), - t("]("), - i(2), - t(")"), - }), -} diff --git a/lua/snippets/tex.lua b/lua/snippets/tex.lua new file mode 100644 index 0000000..30999ea --- /dev/null +++ b/lua/snippets/tex.lua @@ -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) + }) +} diff --git a/lua/snippets/typst.lua b/lua/snippets/typst.lua deleted file mode 100644 index 6caa357..0000000 --- a/lua/snippets/typst.lua +++ /dev/null @@ -1,9 +0,0 @@ -dofile(core.snippets) - -return { - s("title", { - t("#set document(title: ["), - i(1, "theTitle"), - t({ "])", "#title()" }), - }) -} diff --git a/lua/snippets/zig.lua b/lua/snippets/zig.lua index d7e244f..c0bc681 100644 --- a/lua/snippets/zig.lua +++ b/lua/snippets/zig.lua @@ -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);", "}" }), - }), }