Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"mason.nvim": { "branch": "main", "commit": "197f6352c276bbc2d25541dfce00ec50d1a4e88f" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-lspconfig": { "branch": "master", "commit": "4d3b3bb8815fbe37bcaf3dbdb12a22382bc11ebe" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" },
"nvim-web-devicons": { "branch": "master", "commit": "0422a19d9aa3aad2c7e5cca167e5407b13407a9d" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"render-markdown.nvim": { "branch": "main", "commit": "5c0e241bdbd208b7ae546009378d6bc93c083ef3" },
Expand Down
29 changes: 11 additions & 18 deletions .config/nvim/lua/config/format.lua
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
local method = ":silent !"

local python_formatters = { "ruff format" }
local lua_formatters = { "stylua --indent-type Spaces --indent-width 4 --sort-requires" }
local shell_formatters = { "shfmt -w -i 4 -ci" }
local tex_formatters = { "tex-fmt --tab 4" }

local all_formatters = {
python = python_formatters,
lua = lua_formatters,
sh = shell_formatters,
tex = tex_formatters,
latex = tex_formatters,
bib = tex_formatters,
python = { "ruff format" },
lua = { "stylua --indent-type Spaces --indent-width 4 --sort-requires" },
sh = { "shfmt -w -i 4 -ci" },
tex = { "tex-fmt --tab 4" },
latex = { "tex-fmt --tab 4" },
bib = { "tex-fmt --tab 4" },
}

local function format_file()
local file_path = vim.api.nvim_buf_get_name(0)
local file_type = vim.bo.filetype

local formatters = all_formatters[file_type] or {}

vim.cmd("silent write!")

if #formatters == 0 then
print("No formatter available for " .. file_type .. ".")
return
end

vim.cmd("silent write!")

for _, formatter in ipairs(formatters) do
vim.cmd(method .. formatter .. " " .. file_path)
vim.cmd("silent !" .. formatter .. " " .. vim.fn.shellescape(file_path))
end

vim.cmd("edit!")
end

vim.api.nvim_create_user_command("FormatFile", format_file, {})

vim.api.nvim_set_keymap("n", "<leader>F", ":FormatFile<cr>", { noremap = true, silent = true })
vim.keymap.set("n", "<leader>F", "<cmd>FormatFile<cr>", { silent = true })
12 changes: 4 additions & 8 deletions .config/nvim/lua/config/maps.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
local map_group = vim.api.nvim_create_augroup("MapGroup", { clear = true })

local function map(mode, lhs, rhs, opts)
local options = { noremap = true, silent = true }
if opts then
options = vim.tbl_extend("force", options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
vim.keymap.set(mode, lhs, rhs, vim.tbl_extend("force", { silent = true }, opts or {}))
end

vim.g.mapleader = " "
Expand Down Expand Up @@ -41,9 +37,9 @@ map("n", "<leader>sn", ":setlocal nospell<cr>") -- toggle off
-- lsp maps
vim.api.nvim_create_autocmd("LspAttach", {
group = map_group,
callback = function()
map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>")
map("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>")
callback = function(event)
map("n", "gd", vim.lsp.buf.definition, { buffer = event.buf })
map("n", "K", vim.lsp.buf.hover, { buffer = event.buf })
-- map("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>")
end,
})
2 changes: 1 addition & 1 deletion .config/nvim/lua/plugins/config/cmp.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local present1, cmp = pcall(require, "cmp")
local present2, luasnip = pcall(require, "luasnip")
if not (present1 or present2) then
if not (present1 and present2) then
return
end

Expand Down
29 changes: 4 additions & 25 deletions .config/nvim/lua/plugins/config/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
local present1, lspconfig = pcall(require, "lspconfig")
local present2, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not (present1 or present2) then
if not (present1 and present2) then
return
end

local capabilities = cmp_nvim_lsp.default_capabilities()

lspconfig.bashls.setup({
capabilities = capabilities,
})

lspconfig.gopls.setup({
capabilities = capabilities,
})
for _, server in ipairs({ "bashls", "gopls", "pyright", "tinymist", "rust_analyzer", "ts_ls" }) do
lspconfig[server].setup({ capabilities = capabilities })
end

lspconfig.lua_ls.setup({
capabilities = capabilities,
Expand All @@ -25,24 +21,7 @@ lspconfig.lua_ls.setup({
},
})

lspconfig.pyright.setup({
capabilities = capabilities,
})

lspconfig.tinymist.setup({
capabilities = capabilities,
})

lspconfig.rust_analyzer.setup({
capabilities = capabilities,
})

lspconfig.texlab.setup({
filetypes = { "tex", "plaintex", "bib", "latex" },
capabilities = capabilities,
})

lspconfig.ts_ls.setup({
capabilities = capabilities,
})

10 changes: 6 additions & 4 deletions .config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ return {
require("plugins.config.lsp")
end,
dependencies = {
"williamboman/mason.nvim",
config = function()
require("plugins.config.mason")
end,
{
"williamboman/mason.nvim",
config = function()
require("plugins.config.mason")
end,
},
},
}
25 changes: 2 additions & 23 deletions .config/nvim/lua/plugins/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,10 @@ return {
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {
options = {
icons_enabled = true,
theme = "auto",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
options = { theme = "auto", component_separators = "", section_separators = "" },
sections = {
lualine_a = { "mode" },
lualine_b = { { "branch", icons_enabled = false }, "diagonostics" },
lualine_b = { { "branch", icons_enabled = false }, "diagnostics" },
lualine_c = { "filename" },
lualine_x = { "diff", "filetype" },
lualine_y = {},
Expand All @@ -36,9 +19,5 @@ return {
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
},
}
9 changes: 5 additions & 4 deletions .config/nvim/lua/plugins/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ return {
build = "make",
},
},
opts = { theme = "auto" },
keys = {
{ "<leader>/", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "Buffer search" },
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" },
Expand All @@ -28,21 +27,23 @@ return {
},
config = function()
local telescope = require("telescope")
local ignore = { "node_modules", ".git", ".venv", "venv", "svg-inkscape" }

telescope.setup({
pickers = {
live_grep = {
file_ignore_patterns = { "node_modules", ".git", ".venv", "venv", "svg-inkscape" },
file_ignore_patterns = ignore,
additional_args = function(_)
return { "--hidden" }
end,
},
find_files = {
file_ignore_patterns = { "node_modules", ".git", ".venv", "venv", "svg-inkscape" },
file_ignore_patterns = ignore,
hidden = true,
},
},
extensions = {
"fzf",
fzf = {},
["ui-select"] = {
require("telescope.themes").get_dropdown({}),
},
Expand Down
1 change: 0 additions & 1 deletion .config/nvim/lua/plugins/theme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ return {
name = "catppuccin",
lazy = false,
priority = 1000,
opts = {},
config = function()
vim.cmd([[colorscheme catppuccin-macchiato]])
end,
Expand Down
74 changes: 45 additions & 29 deletions .config/nvim/lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
local parsers = {
"bash",
"bibtex",
"diff",
"go",
"gomod",
"gowork",
"gosum",
"html",
"javascript",
"latex",
"typst",
"lua",
"markdown",
"markdown_inline",
"python",
"regex",
"rust",
"toml",
"typescript",
"xml",
}

local filetypes = vim.list_extend(vim.deepcopy(parsers), { "sh", "bib", "tex", "plaintex" })

return {
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"bash",
"bibtex",
"diff",
"go",
"gomod",
"gowork",
"gosum",
"html",
"javascript",
"latex",
"typst",
"lua",
"markdown",
"markdown_inline",
"python",
"regex",
"rust",
"toml",
"typescript",
"xml",
},
indent = { enable = true },
highlight = { enable = true },
playground = { enable = true },
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
branch = "main",
lazy = false,
build = ":TSUpdate",
config = function()
vim.treesitter.language.register("bash", "sh")
vim.treesitter.language.register("bibtex", "bib")
vim.treesitter.language.register("latex", { "tex", "plaintex" })

if vim.fn.executable("tree-sitter") == 1 then
require("nvim-treesitter").install(parsers)
end

vim.api.nvim_create_autocmd("FileType", {
pattern = filetypes,
callback = function()
if pcall(vim.treesitter.start) then
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end,
})
end,
}
7 changes: 0 additions & 7 deletions .config/nvim/lua/snippets-helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@ end

local M = {}

local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local d = ls.dynamic_node
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep

function M.get_ISO_8601_date()
return os.date("%Y-%m-%d")
Expand Down
1 change: 1 addition & 0 deletions bootstrap/pkgs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pandoc,Converts most markup formats
ripgrep,Faster grep
texlive,Distribution for the TeX typesetting system
tmux,Terminal multiplexer
tree-sitter,Incremental parsing system
stow,Organize software neatly under a single directory tree
wget,Retrieves files from web
zathura,Minimalist document viewer
Expand Down