Compare commits

...

16 Commits

Author SHA1 Message Date
c-salomonsen
f42322984e Something old related to ltex and surround idek 2025-09-13 02:09:53 +02:00
c-salomonsen
1a6e75cace update ltex languages to en-US as default 2025-09-13 02:09:25 +02:00
c-salomonsen
ee1e8110a1 Remove auto-folding and set transparency to false by default 2025-09-13 02:09:09 +02:00
c-salomonsen
5b68fda6bb Remove codecompanion and debug stuff, not really in use 2025-09-13 02:08:31 +02:00
salomaestro
3eb6fe5743 Set new folding paradigm 2025-03-21 01:28:15 +01:00
salomaestro
47a191c3c2 Git diff viewer bindings 2025-03-21 01:28:05 +01:00
salomaestro
a61d76d248 Add vimtex 2025-03-21 01:27:49 +01:00
salomaestro
71da2ca93d Add gitsigns blame for normal and visual mode 2025-03-04 15:33:15 +01:00
salomaestro
bb87a70cb2 Add proper LaTeX support (finally) 2025-02-22 01:24:32 +01:00
salomaestro
07cf759d98 Add actions-preview to <leader>gf to show telescope preview of code action changes 2025-02-22 01:24:07 +01:00
salomaestro
f89e212da7 Fixed a long standing bug where <leader>fm didnt format python files correctly 2025-02-22 01:22:59 +01:00
salomaestro
92840f428e Add searchable manpage command 2025-02-19 16:04:06 +01:00
salomaestro
fc5cf565d6 Add binds for searching wiki and navigating journal 2025-02-19 16:03:50 +01:00
salomaestro
5a9c788b08 Add vim-test plugin 2025-02-19 16:02:53 +01:00
salomaestro
3bb580b542 Restructure lspconfig 2025-02-19 16:02:32 +01:00
salomaestro
381fd0140c Change style 2025-02-19 15:59:50 +01:00
8 changed files with 235 additions and 224 deletions

View File

@@ -1,24 +1,30 @@
-- This file needs to have same structure as nvconfig.lua -- This file needs to have same structure as nvconfig.lua
-- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua -- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua
-- Please read that file to know all available options :( -- Please read that file to know all available options :(
---@type ChadrcConfig ---@type ChadrcConfig
local M = {} local M = {}
M.base46 = { M.base46 = {
theme = "monekai", theme = "chadracula",
transparency = false,
-- hl_override = { hl_override = {
-- Comment = { italic = true }, Comment = { italic = true },
-- ["@comment"] = { italic = true }, ["@comment"] = { italic = true },
-- }, },
} }
-- M.nvdash = { load_on_startup = true } M.nvdash = { load_on_startup = true }
-- M.ui = { M.ui = {
-- tabufline = { tabufline = {
-- lazyload = false lazyload = false,
-- } },
--} telescope = { style = "borderless" },
statusline = {
theme = "minimal",
separator_style = "round",
}
}
return M return M

View File

@@ -1,54 +0,0 @@
local cc = require "codecompanion"
cc.setup {
adapters = {
llama3 = function()
return require("codecompanion.adapters").extend("ollama", {
name = "llama3",
schema = {
model = {
default = "llama3.1:latest",
},
},
})
end,
mistral = function()
return require("codecompanion.adapters").extend("ollama", {
name = "mistral",
schema = {
model = {
default = "mistral:latest",
},
},
})
end,
qwen = function()
return require("codecompanion.adapters").extend("ollama", {
name = "qwen",
schema = {
model = {
default = "qwen2.5-coder",
},
},
})
end,
},
strategies = {
chat = {
adapter = "copilot",
},
inline = {
adapter = "copilot",
},
},
display = {
-- diff = {
-- provider = "mini_diff",
-- },
action_palette = {
provider = "mini_pick",
},
},
opts = {
log_level = "DEBUG",
},
}

View File

@@ -4,8 +4,9 @@ local options = {
-- css = { "prettier" }, -- css = { "prettier" },
-- html = { "prettier" }, -- html = { "prettier" },
-- python = { "isort", "black" }, -- python = { "isort", "black" },
python = { "ruff" }, python = { "isort", "ruff_fix", "ruff_format" },
yaml = { "prettier" }, yaml = { "prettier" },
latex = { "bibtex-tidy", "tex-fmt", lsp_format = "fallback" }
}, },
-- format_on_save = { -- format_on_save = {

View File

@@ -1,11 +1,11 @@
-- load defaults i.e lua_lsp -- load defaults i.e lua_lsp
require("nvchad.configs.lspconfig").defaults() local nvlsp = require "nvchad.configs.lspconfig"
local lspconfig = require "lspconfig" local lspconfig = require "lspconfig"
nvlsp.defaults()
-- EXAMPLE -- EXAMPLE
local servers = { "html", "cssls", "ruff", "jedi_language_server", "yls", "lua_ls" } local servers = { "html", "cssls", "ruff", "jedi_language_server", "yls", "lua_ls", "texlab" }
local nvlsp = require "nvchad.configs.lspconfig"
-- lsps with default config -- lsps with default config
for _, lsp in ipairs(servers) do for _, lsp in ipairs(servers) do
@@ -16,12 +16,41 @@ for _, lsp in ipairs(servers) do
} }
end end
-- configuring single server, example: typescript -- lspconfig.texlab.setup({
-- lspconfig.ts_ls.setup { -- settings = {
-- on_attach = nvlsp.on_attach, -- latex = {
-- on_init = nvlsp.on_init, -- build = {
-- capabilities = nvlsp.capabilities, -- executable = "latexmk",
-- } -- args = { "-pdf", "-interaction=nonstopmode", "-synctex=1", "%f" },
-- onSave = true,
-- },
-- },
-- },
-- })
-- Set up LTeX separately
lspconfig.ltex.setup {
on_init = nvlsp.on_init,
capabilities = nvlsp.capabilities,
on_attach = function(client, bufnr)
-- Run NvChad's on_attach for your usual LSP keymaps
nvlsp.on_attach(client, bufnr)
require("ltex_extra").setup {
load_langs = { "en-GB", "en-US", "nb" },
init_check = true,
path = vim.fn.expand("~/.local/share/ltex"), -- where to store language dicts
}
end,
settings = {
ltex = {
language = "en-US",
additionalLanguages = { "nb" },
},
},
}
lspconfig.ruff.setup({ lspconfig.ruff.setup({
init_options = { init_options = {
@@ -33,7 +62,6 @@ lspconfig.ruff.setup({
ignore = {"F401", "W191"}, ignore = {"F401", "W191"},
preview = true, preview = true,
} }
-- Ruff language server settings go here
} }
} }
}) })

View File

@@ -0,0 +1,25 @@
local ls = require "luasnip"
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
return {
-- Italic snippet: type "it" in insert mode and expand to \textit{...}
s({trig="it", desc="Insert italic text"}, {
t "\\textit{",
i(1, "text"),
t "}",
}),
-- Bold snippet example:
s({trig="bf", desc="Insert bold text"}, {
t "\\textbf{",
i(1, "text"),
t "}",
}),
-- Emph snippet example:
s({trig="em", desc="Insert emphasized text"}, {
t "\\emph{",
i(1, "text"),
t "}",
}),
}

View File

@@ -7,12 +7,13 @@ local map = vim.keymap.set
local g = vim.g local g = vim.g
local diag = vim.diagnostic local diag = vim.diagnostic
-- General mappings
map("n", ";", ":", { desc = "CMD enter command mode" }) map("n", ";", ":", { desc = "CMD enter command mode" })
map("i", "jk", "<ESC>") map("i", "jk", "<ESC>")
map("n", "<leader>ca", function() map("n", "j", "gj", { desc = "Move down" })
vim.lsp.buf.code_action() map("n", "k", "gk", { desc = "Move up" })
end, { desc = "LSP code action" })
map("n", "<leader>tt", function() map("n", "<leader>tt", function()
require("base46").toggle_transparency() require("base46").toggle_transparency()
end, { desc = "Toggle transparency" }) end, { desc = "Toggle transparency" })
@@ -47,6 +48,7 @@ function Toggle_diagnostics()
end end
map("n", "<leader>lt", Toggle_diagnostics, { noremap = true, silent = true, desc = "Toggle vim diagnostics" }) map("n", "<leader>lt", Toggle_diagnostics, { noremap = true, silent = true, desc = "Toggle vim diagnostics" })
-- Presistence mappings
-- select a session to load -- select a session to load
map("n", "<leader>qs", function() map("n", "<leader>qs", function()
require("persistence").select() require("persistence").select()
@@ -62,80 +64,86 @@ map("n", "<leader>qd", function()
require("persistence").stop() require("persistence").stop()
end, { desc = "Stop persistence" }) end, { desc = "Stop persistence" })
-- debug related stuff -- mappings for wiki.vim
local dap = require "dap" map("n", "<leader>iw", function ()
require("telescope.builtin").live_grep({
prompt_title = "Search Wiki",
cwd = vim.fn.expand("~/wiki"),
})
end, { desc = "Search Wiki" })
map("n", "<leader>db", function() map("n", "<leader>jn", "<cmd>WikiJournalNext<cr>", { desc = "Next Journal" })
dap.toggle_breakpoint() map("n", "<leader>jp", "<cmd>WikiJournalPrev<cr>", { desc = "Previous Journal" })
end, { desc = "Toggle breakpoint" })
map("n", "<leader>dc", function()
dap.continue()
end, { desc = "Continue" })
map("n", "<leader>dr", function() -- Mappings for Man using ripgrep
dap.repl.open() local actions = require("telescope.actions")
end, { desc = "Open REPL" }) local action_state = require("telescope.actions.state")
local previewers = require("telescope.previewers")
map("n", "<leader>ds", function() -- Define a custom previewer that runs 'man' in a terminal job:
dap.step_over() local man_previewer = previewers.new_termopen_previewer({
end, { desc = "Step over" }) get_command = function(entry)
-- 'entry.value' will be the man-topic, e.g. "ls"
if not entry or not entry.value then
return { "echo", "" }
end
-- The pager string (col -bx | bat -l man -p) must be passed as one argument
-- so that 'man' interprets it as a shell command for the pager:
return {
"man",
"-P", "col -bx | bat -l man -p", -- all as a single argument to -P
entry.value
}
end,
})
map("n", "<leader>di", function() -- Create a mapping that invokes Telescope with our custom previewer
dap.step_into() map("n", "<leader>mp", function()
end, { desc = "Step into" }) require("telescope.builtin").find_files({
prompt_title = "Man Pages",
find_command = {
"bash", "-c",
table.concat({
-- Pipeline:
-- 1) 'rg --files /usr/share/man'
-- 2) strip directory paths (xargs basename)
-- 3) remove trailing .x or .x.gz (sed)
-- 4) sort + unique
"rg --files /usr/share/man",
"| xargs basename",
"| sed 's/\\.[^.]*$//'",
"| sort -u",
}, " ")
},
-- Provide our custom previewer
previewer = man_previewer,
map("n", "<leader>do", function() -- 3) attach_mappings() lets us override what happens when we press <CR>
dap.step_out() attach_mappings = function(prompt_bufnr, map_telescope)
end, { desc = "Step out" }) local function open_man_page()
local selection = action_state.get_selected_entry()
actions.close(prompt_bufnr)
-- Actually open the man page inside Neovim:
vim.cmd("Man " .. selection.value)
end
map("n", "<leader>dT", function() -- Bind <CR> in insert + normal mode to open the man page
dap.terminate() map_telescope("i", "<CR>", open_man_page)
end, { desc = "Terminate" }) map_telescope("n", "<CR>", open_man_page)
map("n", "<leader>dl", function() return true
dap.run_last() end,
end, { desc = "Run Last" }) })
end, { desc = "Search manpages" })
map("n", "<leader>dC", function() -- Mappings for Git stuff
dap.run_to_cursor()
end, { desc = "Run to Cursor" })
-- dapui -- Git blame
map("v", "<leader>gb", "<cmd>lua require('gitsigns').blame_line()<cr>", { desc = "Git Blame line" })
local dapui = require "dapui" map("n", "<leader>gb", "<cmd>lua require('gitsigns').blame()<cr>", { desc = "Git Blame" })
local widgets = require "dap.ui.widgets"
map("n", "<leader>du", function()
dapui.toggle()
end, { desc = "Toggle UI" })
map({ "n", "v" }, "<Leader>dh", function()
widgets.hover()
end, { desc = "Hover" })
map({ "n", "v" }, "<Leader>dp", function()
widgets.preview()
end, { desc = "Preview" })
map("n", "<Leader>df", function()
widgets.centered_float(widgets.frames)
end, { desc = "Frames" })
map("n", "<Leader>ds", function()
widgets.centered_float(widgets.scopes)
end, { desc = "Scopes" })
-- CodeCompletion mappings
map({ "n", "v" }, "<C-a>", "<cmd>CodeCompanionActions<cr>", { noremap = true, silent = true, desc = "Code Actions" })
map({ "n", "v" }, "<Leader>a", "<cmd>CodeCompanionChat Toggle<cr>", { noremap = true, silent = true, desc = "Code Chat" })
map("v", "ga", "<cmd>CodeCompanionChat Add<cr>", { noremap = true, silent = true, desc = "Code Chat Add Visual" })
map("v", "<Leader>ce", function()
require("codecompanion").prompt("explain")
end, { noremap = true, silent = true, desc = "Explain Selection" }
)
-- Expand 'cc' into 'CodeCompanion' in the command line
vim.cmd([[cab cc CodeCompanion]])
-- Git diffview
map("n", "<leader>gd", "<cmd>DiffviewOpen<cr>", { desc = "Git Diff File" })
map("n", "<leader>gD", "<cmd>DiffviewOpen --cached<cr>", { desc = "Git Diff Staged" })
map("n", "<leader>gh", "<cmd>DiffviewFileHistory<cr>", { desc = "Git File History" })

View File

@@ -1,10 +1,27 @@
require "nvchad.options" require "nvchad.options"
-- Set global options
vim.o.cursorlineopt ='both' -- to enable cursorline! vim.o.cursorlineopt ='both' -- to enable cursorline!
vim.o.scrolloff = 10 vim.o.scrolloff = 10
vim.opt.relativenumber = true vim.opt.relativenumber = true
vim.g.wiki_root = "~/wiki" vim.g.wiki_root = "~/wiki"
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
-- Set vimtex options
vim.g.tex_flavour = "latex"
vim.g.vimtex_view_method = "skim"
vim.g.vimtex_view_skim_reading_bar = 1
vim.g.vimtex_view_skim_sync = 1
-- vim.g.vimtex_quickfix_mode = 0
vim.g.vimtex_compiler_method = "latexmk"
vim.g.vimtex_mappings_prefix = "å"
vim.g.complete_close_brackets = 1
-- Set luasnip path
local snippets = require "luasnip.loaders.from_lua"
snippets.load({ paths = "~/.config/nvim/lua/custom/snippets" })
-- Set window-local options
local highlight_group = vim.api.nvim_create_augroup("yankhighlight", { clear = true }) local highlight_group = vim.api.nvim_create_augroup("yankhighlight", { clear = true })
vim.api.nvim_create_autocmd("textyankpost", { vim.api.nvim_create_autocmd("textyankpost", {
callback = function() callback = function()
@@ -14,11 +31,26 @@ vim.api.nvim_create_autocmd("textyankpost", {
pattern = "*", pattern = "*",
}) })
require "dap" -- Surround
local sign = vim.fn.sign_define vim.api.nvim_create_autocmd("FileType", {
pattern = "tex",
callback = function()
vim.b.surround_105 = "\\textit{" .. "\n" .. "}"
vim.b.surround_101 = "\\emph{" .. "\n" .. "}"
vim.b.surround_102 = "\\textbf{" .. "\n" .. "}"
end,
})
sign("DapBreakpoint", { text = "", texthl = "DapBreakpoint", linehl = "", numhl = ""})
sign("DapBreakpointCondition", { text = "", texthl = "DapBreakpointCondition", linehl = "", numhl = ""}) vim.api.nvim_create_autocmd("FileType", {
sign("DapLogPoint", { text = "", texthl = "DapLogPoint", linehl = "", numhl = ""}) pattern = "tex",
sign('DapStopped', { text='', texthl='DapStopped', linehl='DapStopped', numhl= 'DapStopped' }) callback = function()
-- Set a maximum line width of 88 characters
vim.bo.textwidth = 88
-- Ensure 'formatoptions' includes the 't' flag for text wrapping
vim.bo.formatoptions = vim.bo.formatoptions .. "t"
-- Disable conforms formatter so that gq uses Vims native formatter
vim.bo.formatexpr = ""
end,
})

View File

@@ -15,64 +15,14 @@ return {
end, end,
}, },
{
"mfussenegger/nvim-dap",
lazy = true,
},
{ {
"lervag/wiki.vim", "lervag/wiki.vim",
lazy = false, lazy = false,
}, },
{ {
"jay-babu/mason-nvim-dap.nvim", "lervag/vimtex",
opts = { lazy = false,
handlers = {},
automatic_installations = {
exclude = {
"python",
},
},
ensure_installed = {
"python",
},
},
dependencies = {
"mfussenegger/nvim-dap",
"williamboman/mason.nvim",
},
},
{
"mfussenegger/nvim-dap-python",
lazy = true,
config = function()
local python = vim.fn.expand "~/.local/share/nvim/mason/packages/debugpy/venv/bin/python"
require("dap-python").setup(python)
end,
dependencies = {
"mfussenegger/nvim-dap",
},
},
{
"theHamsta/nvim-dap-virtual-text",
config = true,
dependencies = {
"mfussenegger/nvim-dap",
},
},
{
"rcarriga/nvim-dap-ui",
config = true,
dependencies = {
"mfussenegger/nvim-dap",
"mfussenegger/nvim-dap-python",
"nvim-neotest/nvim-nio",
"theHamsta/nvim-dap-virtual-text",
},
}, },
{ {
@@ -92,6 +42,10 @@ return {
"lua", "lua",
"python", "python",
"markdown", "markdown",
"latex",
},
highlight = {
enable = true,
}, },
}, },
}, },
@@ -117,11 +71,6 @@ return {
end, end,
}, },
{
"folke/persistence.nvim",
event = "BufReadPre", -- this will only start session saving when an actual file was opened
},
{ {
"NvChad/nvcommunity", "NvChad/nvcommunity",
{ import = "nvcommunity.git.diffview" }, { import = "nvcommunity.git.diffview" },
@@ -204,19 +153,6 @@ return {
end, end,
}, },
{
"olimorris/codecompanion.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
},
config = function()
require "configs.codecompanion"
end,
lazy = false,
},
-- Install a plugin
{ {
"max397574/better-escape.nvim", "max397574/better-escape.nvim",
event = "InsertEnter", event = "InsertEnter",
@@ -224,4 +160,33 @@ return {
require("better_escape").setup() require("better_escape").setup()
end, end,
}, },
{
"aznhe21/actions-preview.nvim",
keys = {
{
"<leader>gf",
function()
require("actions-preview").code_actions()
end,
mode = { "n", "v" },
desc = "Show code actions",
silent = true,
},
},
config = function()
require("actions-preview").setup {
highlight_command = {
require("actions-preview.highlight").delta(),
},
}
end,
lazy = false,
},
{
"barreiroleo/ltex-extra.nvim",
ft = { "markdown", "tex" },
dependencies = { "neovim/nvim-lspconfig" },
},
} }