moved ftplugins, and fixed some plugins

This commit is contained in:
Jeremie Fraeys 2024-09-15 11:21:15 -04:00
parent 3a09e91ad6
commit 8c56556c86
23 changed files with 578 additions and 244 deletions

View File

@ -8,4 +8,3 @@ collapse_simple_statement = "Never"
[sort_requires] [sort_requires]
enabled = false enabled = false

View File

@ -1,7 +1,7 @@
vim.opt.expandtab = true vim.opt.expandtab = true
vim.opt.shiftwidth = 4 vim.opt.shiftwidth = 2
vim.opt.tabstop = 4 vim.opt.tabstop = 2
vim.opt.expandtab = true vim.opt.softtabstop = 2
vim.opt_local.formatoptions:remove('o') vim.opt_local.formatoptions:remove('o')

88
ftplugin/markdown.lua Normal file
View File

@ -0,0 +1,88 @@
-- markdown.lua
-- Update PATH to include TeX binaries
vim.env.PATH = vim.env.PATH .. ':/Library/TeX/texbin'
-- Utility function to create directories if they do not exist
local function ensure_directory_exists(path)
if not vim.fn.isdirectory(path) then
vim.fn.mkdir(path, 'p')
end
end
-- Generate the PDF target directory and file paths
local function generate_pdf_paths(filename)
local base_dir = vim.fn.fnamemodify(filename, ':h')
local target_dir = base_dir:gsub('/src$', '/pdf')
local output_file = vim.fn.fnamemodify(filename, ':t:r') .. '.pdf'
local output_path = target_dir .. '/' .. output_file
-- Ensure the target directory exists
ensure_directory_exists(target_dir)
return target_dir, output_file, output_path
end
-- Build PDF using the buildnote script
local function build_pdf(filename, output_path)
local command = string.format('buildnote %s %s', vim.fn.shellescape(filename), vim.fn.shellescape(output_path))
return vim.fn.systemlist(command)
end
-- Check if Zathura is running and open it if not
local function open_pdf_in_zathura(pdf_path)
local zathura_running = vim.fn.systemlist('pgrep -f "zathura ' .. vim.fn.shellescape(pdf_path) .. '"')
if #zathura_running == 0 then
vim.fn.jobstart({ 'zathura', pdf_path }, { detach = true, stdout = 'null', stderr = 'null' })
print('Opening PDF in Zathura: ' .. pdf_path)
else
print('Zathura is already running for this file.')
end
end
-- Keybinding to build the PDF and view it in Zathura
vim.keymap.set('n', '<leader>lv', function()
local filename = vim.fn.expand('%:p')
local _, _, output_path = generate_pdf_paths(filename)
-- Build the PDF
local result = build_pdf(filename, output_path)
if #result == 0 then
print('Error: Could not generate PDF.')
return
end
-- Open the PDF in Zathura
open_pdf_in_zathura(output_path)
end, {
desc = 'View output PDF in Zathura',
noremap = true,
silent = true,
})
-- Autocmd to close all Zathura instances related to the current file when exiting Neovim
vim.api.nvim_create_autocmd('VimLeavePre', {
callback = function()
local _, _, output_path = generate_pdf_paths(vim.fn.expand('%:p'))
vim.fn.system({ 'pkill', '-f', 'zathura ' .. output_path })
end,
})
-- Auto-run `buildnote` for files matching `*note-*.md` on save
vim.api.nvim_create_autocmd('BufWritePost', {
pattern = '*note-*.md',
callback = function()
local filename = vim.fn.expand('%:p')
local _, _, output_path = generate_pdf_paths(filename)
if vim.fn.filereadable(filename) == 1 then
-- Execute the buildnote script to generate the PDF
local command = string.format('buildnote %s %s', vim.fn.shellescape(filename), vim.fn.shellescape(output_path))
vim.cmd('silent !' .. command)
else
print('Error: File ' .. filename .. ' does not exist.')
end
end,
})

View File

@ -1,21 +1,103 @@
-- LaTeX keybindings and Zathura management
-- Keybinding to compile LaTeX to PDF using xelatex with latexmk and output to the "output" directory -- Keybinding to compile LaTeX to PDF using xelatex with latexmk and output to the "output" directory
vim.keymap.set('n', '<leader>ll', ':!mkdir -p output && latexmk -pdf -xelatex -output-directory=output -synctex=1 %<CR>', vim.keymap.set(
'n',
'<leader>ll',
':!mkdir -p output && latexmk -pdf -xelatex -output-directory=output -synctex=1 %<CR>',
{ {
desc = 'Compile LaTeX to PDF using xelatex with SyncTeX in the output directory', desc = 'Compile LaTeX to PDF using xelatex with SyncTeX in the output directory',
noremap = true, noremap = true,
silent = true silent = true,
}) }
)
-- Keybinding to view the compiled PDF in Zathura from the output directory -- Keybinding to view the compiled PDF in Zathura from the output directory
vim.keymap.set('n', '<leader>lv', function() vim.keymap.set('n', '<leader>lv', function()
local pdf_path = vim.fn.expand('%:p:h') .. '/output/' .. vim.fn.expand('%:t:r') .. '.pdf' local pdf_path = vim.fn.expand('%:p:h/output/%:t:r.pdf')
vim.cmd(':silent !nohup zathura ' .. pdf_path .. ' >/dev/null 2>&1 &')
-- Check if Zathura is already running for this PDF
local zathura_running = vim.fn.systemlist('pgrep -f "zathura ' .. pdf_path .. '"')
if #zathura_running == 0 then
-- Start Zathura if it's not already running for this PDF
vim.fn.jobstart({ 'zathura', pdf_path }, { detach = true, stdout = 'null', stderr = 'null' })
else
print('Zathura is already running for this file.')
end
end, { end, {
desc = 'View PDF in Zathura from the output directory', desc = 'View PDF in Zathura from the output directory',
noremap = true, noremap = true,
silent = true silent = true,
}) })
-- Custom surroundings for LaTeX -- Function to close the Zathura instance for the current PDF
vim.g.surround_110 = "\\begin{\r}\n\\end{\r}" -- map `yssn` for \begin{} \end{} local function close_zathura()
local pdf_path = vim.fn.expand('%:p:h') .. '/output/' .. vim.fn.expand('%:t:r') .. '.pdf'
-- Terminate Zathura process associated with the PDF
vim.fn.system({ 'pkill', '-f', 'zathura ' .. pdf_path })
end
-- Keybinding to close Zathura for the current PDF
vim.keymap.set(
'n',
'<leader>lc', -- Replace with your preferred key combination
close_zathura,
{
desc = 'Close Zathura instance for the current PDF',
noremap = true,
silent = true,
}
)
-- Prevent multiple Zathura instances and add cooldown period
local last_open_time = 0
local cooldown_period = 5 -- Cooldown period in seconds
local max_instances = 5
local zathura_pids = {}
local auto_close_min = 180
-- Function to schedule Zathura closure after a delay in minutes
local function schedule_close_zathura(minutes)
local delay_ms = minutes * 60 * 1000 -- Convert minutes to milliseconds
vim.defer_fn(close_zathura, delay_ms)
end
-- Autocmd to automatically open the PDF in Zathura when a .tex file is opened
vim.api.nvim_create_autocmd('BufEnter', {
pattern = '*.tex',
callback = function()
local current_time = vim.fn.reltimefloat(vim.fn.reltime())
if current_time - last_open_time < cooldown_period then
print('Cooldown active, skipping Zathura launch.')
return
end
last_open_time = current_time
if #zathura_pids >= max_instances then
print('Maximum number of Zathura instances reached.')
return
end
local pdf_path = vim.fn.expand('%:p:h') .. '/output/' .. vim.fn.expand('%:t:r') .. '.pdf'
local zathura_running = vim.fn.systemlist('pgrep -f "zathura ' .. pdf_path .. '"')
if #zathura_running == 0 and vim.fn.filereadable(pdf_path) == 1 then
local job_id = vim.fn.jobstart({ 'zathura', pdf_path }, { detach = true })
table.insert(zathura_pids, job_id)
-- Schedule the closure of Zathura after 180 minutes (3 hours)
schedule_close_zathura(auto_close_min)
else
print('Zathura is already running for this file or PDF not found.')
end
end,
})
-- Autocmd to close all Zathura instances related to the current file when exiting Neovim
vim.api.nvim_create_autocmd('VimLeavePre', {
callback = function()
local pdf_path = vim.fn.expand('%:p:h') .. '/output/' .. vim.fn.expand('%:t:r') .. '.pdf'
vim.fn.system({ 'pkill', '-f', 'zathura ' .. pdf_path })
end,
})

View File

@ -1,10 +1,10 @@
-- Auto-format on save -- Auto-format on save
vim.cmd [[ vim.cmd([[
augroup FormatOnSave augroup FormatOnSave
autocmd! autocmd!
autocmd BufWritePre * lua vim.lsp.buf.format({ async = false }) autocmd BufWritePre * lua vim.lsp.buf.format({ async = false })
augroup END augroup END
]] ]])
-- Augroup for Highlight on yank -- Augroup for Highlight on yank
vim.cmd([[ vim.cmd([[
@ -63,30 +63,3 @@ vim.cmd([[
autocmd TermOpen * normal! G autocmd TermOpen * normal! G
autocmd TermOpen * tnoremap <Esc> <C-\><C-n> autocmd TermOpen * tnoremap <Esc> <C-\><C-n>
]]) ]])
-- Open PDF in the background when a .tex file is opened
vim.api.nvim_create_autocmd("BufEnter", {
pattern = "*.tex",
callback = function()
-- Construct an absolute path to the PDF file
local pdf_path = vim.fn.expand('%:p:h') .. "/output/" .. vim.fn.expand('%:t:r') .. '.pdf'
if vim.fn.filereadable(pdf_path) == 1 then
-- Start Zathura asynchronously in the background with an absolute path
vim.fn.jobstart({ 'nohup', 'zathura', pdf_path, '>/dev/null', '2>&1', '&' }, { detach = true })
else
print("PDF file not found: " .. pdf_path)
end
end,
})
-- Close Zathura gracefully when leaving Neovim
vim.api.nvim_create_autocmd("VimLeavePre", {
callback = function()
-- Attempt to terminate Zathura gracefully with a grace period
vim.fn.system({ 'pkill', '-TERM', '-f', 'zathura' })
vim.defer_fn(function()
vim.fn.system({ 'pkill', '-KILL', '-f', 'zathura' })
end, 2000) -- Wait for 2 seconds before force killing if necessary
end,
})

View File

@ -6,6 +6,7 @@ local utils = require('config.utils')
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" }) -- vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" })
vim.keymap.set('n', '<C-c>', '<ESC><ESC>', { silent = true }) vim.keymap.set('n', '<C-c>', '<ESC><ESC>', { silent = true })
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>', { silent = true })
-- Remap for dealing with word wrap -- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
@ -21,8 +22,8 @@ vim.keymap.set('n', '<', '<gv', { silent = true })
vim.keymap.set('n', 'J', 'mzj`z') vim.keymap.set('n', 'J', 'mzj`z')
vim.keymap.set('n', '<c-d>', '<C-d>zz', { desc = 'Half Page Jumping Up' }) vim.keymap.set('n', '<c-d>', '<C-d>zz', { desc = 'Half Page Jumping Up' })
vim.keymap.set('n', '<c-u>', '<C-u>zz', { desc = 'Half Page Jumping Down' }) vim.keymap.set('n', '<c-u>', '<C-u>zz', { desc = 'Half Page Jumping Down' })
vim.keymap.set('n', 'n', 'nzzzv', { silent = true }) vim.keymap.set('n', 'n', 'nzzzv', { noremap = true, silent = true })
vim.keymap.set('n', 'N', 'Nzzzv', { silent = true }) vim.keymap.set('n', 'N', 'Nzzzv', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'gp', '<Nop>', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', 'gp', '<Nop>', { noremap = true, silent = true })
vim.keymap.set('n', '<C-k>', '<cmd>cnext<CR>zz') vim.keymap.set('n', '<C-k>', '<cmd>cnext<CR>zz')
vim.keymap.set('n', '<C-j>', '<cmd>cprev<CR>zz') vim.keymap.set('n', '<C-j>', '<cmd>cprev<CR>zz')
@ -133,4 +134,3 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnos
-- { noremap = true, silent = true, expr = false, desc = "Extract Block" }) -- { noremap = true, silent = true, expr = false, desc = "Extract Block" })
-- vim.keymap.set({ "n" }, "<leader>rbf", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Block To File')<CR>]], -- vim.keymap.set({ "n" }, "<leader>rbf", [[<Esc><Cmd>lua require('refactoring').refactor('Extract Block To File')<CR>]],
-- { noremap = true, silent = true, expr = false, desc = "Extract Block To File" }) -- { noremap = true, silent = true, expr = false, desc = "Extract Block To File" })

View File

@ -54,6 +54,15 @@ local opts = {
termguicolors = true, termguicolors = true,
scrolloff = 10, scrolloff = 10,
pyxversion = 3, pyxversion = 3,
-- Sets how neovim will display certain whitespace characters in the editor.
-- See :help 'list'
-- and :help 'listchars'
list = true,
listchars = { tab = ' ', trail = '·', nbsp = '' },
-- Preview substitutions live, as you type!
inccommand = 'split',
} }
for k, v in pairs(opts) do for k, v in pairs(opts) do
@ -124,4 +133,3 @@ opt.formatoptions = opt.formatoptions
+ 'n' -- Indent past the formatlistpat, not underneath it. + 'n' -- Indent past the formatlistpat, not underneath it.
+ 'j' -- Auto-remove comments if possible. + 'j' -- Auto-remove comments if possible.
- '2' -- I'm not in gradeschool anymore - '2' -- I'm not in gradeschool anymore

View File

@ -1,19 +1,14 @@
return { return {
'f-person/auto-dark-mode.nvim', 'f-person/auto-dark-mode.nvim',
event = 'VimEnter', -- Lazy load on VimEnter event
opts = { opts = {
update_interval = 1000, -- Check for mode change every second update_interval = 2000,
set_dark_mode = function() set_dark_mode = function()
vim.api.nvim_set_option_value('background', 'dark', {})
vim.cmd('colorscheme monokai') vim.cmd('colorscheme monokai')
vim.cmd('set background=dark') -- Ensure the background is set correctly
end, end,
set_light_mode = function() set_light_mode = function()
vim.api.nvim_set_option_value('background', 'light', {})
vim.cmd('colorscheme solarized') vim.cmd('colorscheme solarized')
vim.cmd('set background=light')
end, end,
}, },
config = function(_, opts)
require('auto-dark-mode').setup(opts)
end
} }

View File

@ -10,4 +10,3 @@ return {
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end, end,
} }

View File

@ -3,75 +3,42 @@ return {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
dependencies = { dependencies = {
-- Snippet Engine & its associated nvim-cmp source -- Snippet Engine & its associated nvim-cmp source
'L3MON4D3/LuaSnip', { 'L3MON4D3/LuaSnip', lazy = true },
'saadparwaiz1/cmp_luasnip', { 'saadparwaiz1/cmp_luasnip', lazy = true },
-- Adds LSP completion capabilities -- Adds LSP completion capabilities
'hrsh7th/cmp-nvim-lsp', { 'hrsh7th/cmp-nvim-lsp' },
-- Adds a number of user-friendly snippets -- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets', { 'rafamadriz/friendly-snippets', lazy = true },
-- Optional sources -- Optional sources for path and buffer completion
'hrsh7th/cmp-path', { 'hrsh7th/cmp-path', lazy = true },
'hrsh7th/cmp-buffer', { 'hrsh7th/cmp-buffer', lazy = true },
-- Optional: additional completions for cmdline and git
{ 'hrsh7th/cmp-cmdline', lazy = true },
{ 'petertriho/cmp-git', lazy = true }, -- Git completions for commit messages
-- Optional: icons for completion menu
{ 'onsails/lspkind-nvim', lazy = true }, -- Adds nice icons to completion
}, },
event = { 'InsertEnter', 'CmdlineEnter' }, event = { 'InsertEnter', 'CmdlineEnter' },
config = function() config = function()
local cmp = require('cmp')
local luasnip = require('luasnip')
local lspkind = require('lspkind')
-- Set completion options -- Set completion options
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
-- Import required modules local cmp_mappings = {
local cmp = require('cmp')
local luasnip = require('luasnip')
-- Setup luasnip
luasnip.config.setup({
history = true,
updateevents = 'TextChanged,TextChangedI',
})
-- Lazy load snippets from friendly-snippets and custom snippets
require('luasnip.loaders.from_vscode').lazy_load()
require('luasnip.loaders.from_vscode').load(vim.fn.stdpath('config') .. '/snippets')
-- Setup nvim-cmp
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = { 'abbr', 'kind', 'menu' },
format = function(entry, item)
local menu_icon = {
nvim_lsp = 'λ',
luasnip = '',
buffer = 'Ω',
path = '🖫',
}
item.menu = menu_icon[entry.source.name] or entry.source.name
return item
end,
},
mapping = cmp.mapping.preset.insert({
['<C-n>'] = cmp.mapping.select_next_item(), ['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(), ['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete(), -- Trigger completion
['<CR>'] = cmp.mapping.confirm({ select = true }), ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Confirm selection
['<C-l>'] = cmp.mapping(function(fallback) ['<C-l>'] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
@ -90,8 +57,51 @@ return {
fallback() fallback()
end end
end, { 'i', 's' }), end, { 'i', 's' }),
['<C-e>'] = cmp.mapping.abort(), ['<C-e>'] = cmp.mapping.abort(), -- Abort completion
}
-- Setup LuaSnip configuration
luasnip.config.setup({
history = true,
updateevents = 'TextChanged,TextChangedI',
})
-- Lazy load snippets from friendly-snippets and custom snippets
require('luasnip.loaders.from_vscode').lazy_load()
require('luasnip.loaders.from_vscode').load(vim.fn.stdpath('config') .. '/snippets')
-- Setup nvim-cmp
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- Expand snippets
end,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- LSP completions
{ name = 'luasnip' }, -- Snippet completions
{ name = 'path' }, -- Path completions
{ name = 'buffer' }, -- Buffer completions
}), }),
window = {
completion = cmp.config.window.bordered(), -- Border for completion window
documentation = cmp.config.window.bordered(), -- Border for documentation window
},
formatting = {
fields = { 'abbr', 'kind', 'menu' },
format = lspkind.cmp_format({ -- Use lspkind for icons
with_text = true,
menu = {
nvim_lsp = '[LSP]',
luasnip = '[Snip]',
buffer = '[Buffer]',
path = '[Path]',
cmdline = '[Cmd]',
git = '[Git]',
},
}),
},
mapping = cmp.mapping.preset.insert(cmp_mappings),
}) })
-- Setup for SQL filetype with vim-dadbod-completion -- Setup for SQL filetype with vim-dadbod-completion
@ -101,6 +111,36 @@ return {
{ name = 'buffer' }, { name = 'buffer' },
}), }),
}) })
-- Setup for markdown with buffer-only completions
cmp.setup.filetype('markdown', {
sources = cmp.config.sources({
{ name = 'buffer' },
}),
})
-- Setup for cmdline '/' (search) and ':' (command) mode
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(cmp_mappings),
sources = {
{ name = 'buffer' },
},
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(cmp_mappings),
sources = cmp.config.sources({
{ name = 'path' },
{ name = 'cmdline' },
}),
})
-- Setup git commit message completion
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' },
{ name = 'buffer' },
}),
})
end, end,
} }

View File

@ -2,4 +2,3 @@ return {
'numToStr/Comment.nvim', 'numToStr/Comment.nvim',
opts = {}, opts = {},
} }

View File

@ -17,4 +17,3 @@ return {
}, },
}, },
} }

View File

@ -1,14 +1,17 @@
return { return {
'tpope/vim-dadbod',
dependencies = {
'kristijanhusak/vim-dadbod-ui', 'kristijanhusak/vim-dadbod-ui',
'kristijanhusak/vim-dadbod-completion', dependencies = {
{ 'tpope/vim-dadbod', lazy = true },
{ 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, -- Optional
}, },
keys = { cmd = {
{ '<leader>du', '<cmd>DBUIToggle<cr>', { desc = 'Toggle dadbod', noremap = true } }, 'DBUI',
'DBUIToggle',
'DBUIAddConnection',
'DBUIFindBuffer',
}, },
init = function() init = function()
-- Your DBUI configuration
vim.g.db_ui_use_nerd_fonts = 1 vim.g.db_ui_use_nerd_fonts = 1
end, end,
} }

View File

@ -1,16 +1,16 @@
return { return {
-- Add the nvim-dap related plugins -- add the nvim-dap related plugins
{ {
'mfussenegger/nvim-dap', 'mfussenegger/nvim-dap',
dependencies = { dependencies = {
{ 'rcarriga/nvim-dap-ui', opt = true, cmd = 'DapUI' }, { 'rcarriga/nvim-dap-ui', opt = true, cmd = 'Dapui' },
{ 'nvim-neotest/nvim-nio', opt = true, cmd = 'Neotest' }, { 'nvim-neotest/nvim-nio', opt = true, cmd = 'Neotest' },
{ 'theHamsta/nvim-dap-virtual-text', opt = true, ft = { 'python', 'go', 'rust' } }, { 'thehamsta/nvim-dap-virtual-text', opt = true, ft = { 'python', 'go', 'rust' } },
{ 'mfussenegger/nvim-dap-python', opt = true, ft = 'python' }, { 'mfussenegger/nvim-dap-python', opt = true, ft = 'python' },
{ 'leoluz/nvim-dap-go', opt = true, ft = 'go' }, { 'leoluz/nvim-dap-go', opt = true, ft = 'go' },
{ 'simrat39/rust-tools.nvim', opt = true, ft = 'rust' }, { 'simrat39/rust-tools.nvim', opt = true, ft = 'rust' },
'williamboman/mason.nvim', -- Mason for managing external tools 'williamboman/mason.nvim', -- mason for managing external tools
'williamboman/mason-lspconfig.nvim' 'williamboman/mason-lspconfig.nvim',
}, },
config = function() config = function()
local dap = require('dap') local dap = require('dap')
@ -18,26 +18,16 @@ return {
local dap_virtual_text = require('nvim-dap-virtual-text') local dap_virtual_text = require('nvim-dap-virtual-text')
local mason_registry = require('mason-registry') local mason_registry = require('mason-registry')
-- Initialize dap-ui -- initialize dap-ui
dapui.setup() dapui.setup()
-- Initialize dap-virtual-text -- initialize dap-virtual-text
dap_virtual_text.setup() dap_virtual_text.setup()
-- Keybindings -- dap python
vim.api.nvim_set_keymap('n', '<leader>dc', ':lua require"dap".continue()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ds', ':lua require"dap".step_over()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>di', ':lua require"dap".step_into()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>do', ':lua require"dap".step_out()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>db', ':lua require"dap".toggle_breakpoint()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>dr', ':lua require"dap".repl.open()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>du', ':lua require"dapui".toggle()<CR>', { noremap = true, silent = true })
-- DAP Python
local function get_python_path() local function get_python_path()
local cwd = vim.fn.getcwd() local cwd = vim.fn.getcwd()
if vim.env.VIRTUAL_ENV then if vim.env.virtual_env then
return vim.env.VIRTUAL_ENV .. '/bin/python' return vim.env.virtual_env .. '/bin/python'
elseif vim.fn.executable(cwd .. '/venv/bin/python') == 1 then elseif vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
return cwd .. '/venv/bin/python' return cwd .. '/venv/bin/python'
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
@ -49,13 +39,13 @@ return {
require('dap-python').setup(get_python_path()) require('dap-python').setup(get_python_path())
-- DAP Go -- dap go
require('dap-go').setup() require('dap-go').setup()
-- DAP Rust -- dap rust
local rust_tools = require('rust-tools') local rust_tools = require('rust-tools')
-- Ensure codelldb is installed via Mason -- ensure codelldb is installed via mason
local codelldb_package = mason_registry.get_package('codelldb') local codelldb_package = mason_registry.get_package('codelldb')
local codelldb_path = codelldb_package:get_install_path() local codelldb_path = codelldb_package:get_install_path()
local codelldb_adapter = codelldb_path .. '/extension/adapter/codelldb' local codelldb_adapter = codelldb_path .. '/extension/adapter/codelldb'
@ -63,55 +53,121 @@ return {
rust_tools.setup({ rust_tools.setup({
tools = { tools = {
autoSetHints = true, autosethints = true,
inlay_hints = { inlay_hints = {
show_parameter_hints = true, show_parameter_hints = true,
parameter_hints_prefix = "<- ", parameter_hints_prefix = '<- ',
other_hints_prefix = "=> ", other_hints_prefix = '=> ',
}, },
}, },
server = { server = {
on_attach = function(_, bufnr) on_attach = function(_, bufnr)
-- DAP Rust keymaps -- dap rust keymaps
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>dr', ':RustDebuggables<CR>', { noremap = true, silent = true }) vim.api.nvim_buf_set_keymap(
-- Keybind for RustHoverActions bufnr,
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', ':RustHoverActions<CR>', { noremap = true, silent = true }) 'n',
'<leader>dr',
':rustdebuggables<cr>',
{ noremap = true, silent = true }
)
-- keybind for rusthoveractions
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'k', ':rusthoveractions<cr>', { noremap = true, silent = true })
end, end,
}, },
dap = { dap = {
adapter = require('rust-tools.dap').get_codelldb_adapter( adapter = require('rust-tools.dap').get_codelldb_adapter(codelldb_adapter, codelldb_lib),
codelldb_adapter,
codelldb_lib
),
}, },
}) })
-- DAP UI integration -- dap ui integration
dap.listeners.after.event_initialized["dapui_config"] = function() dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open() dapui.open()
end end
dap.listeners.before.event_terminated["dapui_config"] = function() dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close() dapui.close()
end end
dap.listeners.before.event_exited["dapui_config"] = function() dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close() dapui.close()
end end
-- Define signs for breakpoints -- define signs for breakpoints
vim.fn.sign_define('DapBreakpoint', { text = '🔴', texthl = '', linehl = '', numhl = '' }) vim.fn.sign_define('dapbreakpoint', { text = '🔴', texthl = '', linehl = '', numhl = '' })
vim.fn.sign_define('DapStopped', { text = '🟢', texthl = '', linehl = '', numhl = '' }) vim.fn.sign_define('dapstopped', { text = '🟢', texthl = '', linehl = '', numhl = '' })
end, end,
keys = { keys = {
{ 'n', '<leader>dc', ':lua require"dap".continue()<CR>' }, {
{ 'n', '<leader>ds', ':lua require"dap".step_over()<CR>' }, '<leader>dc',
{ 'n', '<leader>di', ':lua require"dap".step_into()<CR>' }, function()
{ 'n', '<leader>do', ':lua require"dap".step_out()<CR>' }, require('dap').continue()
{ 'n', '<leader>db', ':lua require"dap".toggle_breakpoint()<CR>' }, end,
{ 'n', '<leader>dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))<CR>' }, mode = 'n',
{ 'n', '<leader>dr', ':lua require"dap".repl.open()<CR>' }, noremap = true,
{ 'n', '<leader>du', ':lua require"dapui".toggle()<CR>' } silent = true,
},
{
'<leader>ds',
function()
require('dap').step_over()
end,
mode = 'n',
noremap = true,
silent = true,
},
{
'<leader>di',
function()
require('dap').step_into()
end,
mode = 'n',
noremap = true,
silent = true,
},
{
'<leader>do',
function()
require('dap').step_out()
end,
mode = 'n',
noremap = true,
silent = true,
},
{
'<leader>db',
function()
require('dap').toggle_breakpoint()
end,
mode = 'n',
noremap = true,
silent = true,
},
{
'<leader>dsb',
function()
require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))
end,
mode = 'n',
noremap = true,
silent = true,
},
{
'<leader>dr',
function()
require('dap').repl.open()
end,
mode = 'n',
noremap = true,
silent = true,
},
{
'<leader>du',
function()
require('dapui').toggle()
end,
mode = 'n',
noremap = true,
silent = true,
},
},
ft = { 'python', 'go', 'rust' },
}, },
ft = { 'python', 'go', 'rust' }
}
} }

View File

@ -5,6 +5,17 @@ return {
'WhoIsSethDaniel/mason-tool-installer.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim',
}, },
event = { 'BufReadPre', 'BufNewFile' }, event = { 'BufReadPre', 'BufNewFile' },
cmd = { 'ConformInfo' },
keys = {
{
'<leader>f',
function()
require('conform').format({ async = true, lsp_fallback = true })
end,
mode = '',
desc = '[F]ormat buffer',
},
},
opts = function() opts = function()
local formatters_by_ft = { local formatters_by_ft = {
lua = { 'stylua' }, lua = { 'stylua' },
@ -16,33 +27,38 @@ return {
end end
end, end,
go = { 'gofumpt', 'goimports' }, go = { 'gofumpt', 'goimports' },
yaml = { 'prettier' }, -- Added YAML formatter yaml = { 'prettier' },
bash = { 'shfmt' }, -- Added Bash formatter bash = { 'shfmt' },
rust = { 'rustfmt' }, -- Added Rust formatter rust = { 'rustfmt' },
dockerfile = { 'hadolint' }, -- Added Dockerfile formatter dockerfile = { 'hadolint' },
} }
require('conform').setup({ return {
formatters_by_ft = formatters_by_ft, notify_on_error = false,
format_on_save = { format_on_save = function(bufnr)
lsp_fallback = true, local disable_filetypes = { c = true, cpp = true }
return {
timeout_ms = 500, timeout_ms = 500,
}, lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
}) }
end,
formatters_by_ft = formatters_by_ft,
}
end,
config = function(_, opts)
require('conform').setup(opts)
require('mason-tool-installer').setup({ require('mason-tool-installer').setup({
ensure_installed = { ensure_installed = {
'stylua', -- Lua 'stylua',
'ruff', -- Python 'ruff',
'isort', -- Python 'isort',
'black', -- Python 'black',
'gofumpt', -- Go 'gofumpt',
'goimports', -- Go 'goimports',
'prettier', -- YAML, JSON, etc. 'shfmt',
'shfmt', -- Bash 'hadolint',
'hadolint', -- Dockerfile
}, },
}) })
end, end,
} }

View File

@ -14,7 +14,8 @@ return {
-- on_attach function executed when the plugin is attached to a buffer -- on_attach function executed when the plugin is attached to a buffer
on_attach = function(bufnr) on_attach = function(bufnr)
vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, {
buffer = bufnr, desc = 'Preview git hunk' buffer = bufnr,
desc = 'Preview git hunk',
}) })
-- Don't override built-in and fugitive keymaps -- Don't override built-in and fugitive keymaps
@ -42,4 +43,3 @@ return {
}, },
}, },
} }

View File

@ -15,6 +15,7 @@ return {
lua = { 'luacheck' }, -- Added Lua linter lua = { 'luacheck' }, -- Added Lua linter
rust = { 'clippy' }, -- Use `clippy` for Rust linting rust = { 'clippy' }, -- Use `clippy` for Rust linting
dockerfile = { 'hadolint' }, -- Added Dockerfile linter dockerfile = { 'hadolint' }, -- Added Dockerfile linter
-- rust = { 'clippy' }, -- Use `clippy` for Rust linting
} }
-- Autocommand group for triggering linting -- Autocommand group for triggering linting
@ -36,6 +37,7 @@ return {
-- Mason tool installer setup -- Mason tool installer setup
require('mason-tool-installer').setup({ require('mason-tool-installer').setup({
ensure_installed = { ensure_installed = {
-- 'clippy', -- Rust
'ruff', -- Python 'ruff', -- Python
-- 'mypy', -- Uncomment if needed for additional Python linting -- 'mypy', -- Uncomment if needed for additional Python linting
'golangci-lint', -- Go 'golangci-lint', -- Go
@ -47,4 +49,3 @@ return {
}) })
end, end,
} }

View File

@ -10,6 +10,7 @@ return {
'j-hui/fidget.nvim', 'j-hui/fidget.nvim',
tag = 'legacy', tag = 'legacy',
opts = {}, opts = {},
event = 'LspAttach', -- Lazy load on LSP attachment
}, },
-- Additional Lua configuration -- Additional Lua configuration
@ -54,7 +55,9 @@ return {
}, },
}, },
}, },
rust_analyzer = { cmd = { 'rustup', 'run', 'stable', 'rust-analyzer' } }, rust_analyzer = {
cmd = { 'rustup', 'run', 'stable', 'rust-analyzer' },
},
texlab = { texlab = {
flags = { flags = {
debounce_text_changes = 150, debounce_text_changes = 150,
@ -62,13 +65,13 @@ return {
settings = { settings = {
texlab = { texlab = {
build = { build = {
executable = "latexmk", executable = 'latexmk',
args = { "-pdf", "-xelatex", "-output-directory=output", "-interaction=nonstopmode", "-synctex=1", "%f" }, args = { '-pdf', '-xelatex', '-output-directory=output', '-interaction=nonstopmode', '-synctex=1', '%f' },
onSave = true, onSave = true,
}, },
forwardSearch = { forwardSearch = {
executable = "zathura", executable = 'zathura',
args = { "--synctex-forward", "%l:1:%f", "%p" }, args = { '--synctex-forward', '%l:1:%f', '%p' },
}, },
}, },
}, },
@ -87,6 +90,13 @@ return {
}, },
}, },
}, },
marksman = {
filetypes = { 'markdown' },
root_dir = function(fname)
return require('lspconfig.util').root_pattern('.marksman.toml', '.git')(fname) or vim.loop.cwd()
end,
settings = {},
},
yamlls = { yamlls = {
filetypes = { 'yaml' }, filetypes = { 'yaml' },
settings = { settings = {
@ -156,11 +166,12 @@ return {
spacing = 2, spacing = 2,
}, },
float = { float = {
Source = 'if_many', source = 'if_many',
border = 'rounded', border = 'rounded',
}, },
}) })
-- Define diagnostic signs
local sign = function(opts) local sign = function(opts)
vim.fn.sign_define(opts.name, { vim.fn.sign_define(opts.name, {
texthl = opts.name, texthl = opts.name,
@ -174,10 +185,8 @@ return {
sign({ name = 'DiagnosticSignHint', text = '' }) sign({ name = 'DiagnosticSignHint', text = '' })
sign({ name = 'DiagnosticSignInfo', text = '»' }) sign({ name = 'DiagnosticSignInfo', text = '»' })
-- Fidget configuration (LSP progress)
require('fidget').setup({})
-- Neodev setup for improved Lua development -- Neodev setup for improved Lua development
require('fidget').setup({})
require('neodev').setup({ require('neodev').setup({
library = { library = {
plugins = { 'nvim-dap-ui' }, plugins = { 'nvim-dap-ui' },
@ -186,4 +195,3 @@ return {
}) })
end, end,
} }

View File

@ -1,4 +0,0 @@
return {
'iamcco/markdown-preview.nvim',
}

View File

@ -5,8 +5,20 @@ return {
'L3MON4D3/LuaSnip', 'L3MON4D3/LuaSnip',
}, },
keys = { keys = {
{ '<leader>nf', function() require('neogen').generate({ type = 'func' }) end, desc = 'Generate function doc' }, {
{ '<leader>nt', function() require('neogen').generate({ type = 'type' }) end, desc = 'Generate type doc' }, '<leader>nf',
function()
require('neogen').generate({ type = 'func' })
end,
desc = 'Generate function doc',
},
{
'<leader>nt',
function()
require('neogen').generate({ type = 'type' })
end,
desc = 'Generate type doc',
},
}, },
config = function() config = function()
require('neogen').setup({ require('neogen').setup({
@ -16,4 +28,3 @@ return {
-- Uncomment next line if you want to follow only stable versions -- Uncomment next line if you want to follow only stable versions
-- version = "*" -- version = "*"
} }

View File

@ -1,8 +1,7 @@
return { return {
'shaunsingh/solarized.nvim', 'shaunsingh/solarized.nvim',
event = "VeryLazy", event = 'VeryLazy',
config = function() config = function()
vim.g.solarized_variant = 'light' vim.g.solarized_variant = 'light'
end, end,
} }

View File

@ -0,0 +1,7 @@
-- Highlight todo, notes, etc in comments
return {
'folke/todo-comments.nvim',
event = 'VimEnter',
dependencies = { 'nvim-nua/plenary.nvim' },
opts = { signs = false },
}

View File

@ -1,18 +1,73 @@
return { -- return {
'folke/which-key.nvim', -- 'folke/which-key.nvim',
event = 'VimEnter', -- event = 'VimEnter',
opts = { -- opts = {
plugins = { -- plugins = {
marks = true, -- marks = true,
registers = true, -- registers = true,
spelling = { -- spelling = {
enabled = true, -- enabled = true,
suggestions = 20, -- suggestions = 20,
}, -- },
}, -- },
windows = { -- windows = {
border = 'single', -- border = 'single',
}, -- },
}, -- },
} -- }
return { -- Useful plugin to show you pending keybinds.
'folke/which-key.nvim',
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
config = function() -- This is the function that runs, AFTER loading
require('which-key').setup({
icons = {
-- set icon mappings to true if you have a Nerd Font
mappings = vim.g.have_nerd_font,
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
keys = vim.g.have_nerd_font and {} or {
Up = '<Up> ',
Down = '<Down> ',
Left = '<Left> ',
Right = '<Right> ',
C = '<C-…> ',
M = '<M-…> ',
D = '<D-…> ',
S = '<S-…> ',
CR = '<CR> ',
Esc = '<Esc> ',
ScrollWheelDown = '<ScrollWheelDown> ',
ScrollWheelUp = '<ScrollWheelUp> ',
NL = '<NL> ',
BS = '<BS> ',
Space = '<Space> ',
Tab = '<Tab> ',
F1 = '<F1>',
F2 = '<F2>',
F3 = '<F3>',
F4 = '<F4>',
F5 = '<F5>',
F6 = '<F6>',
F7 = '<F7>',
F8 = '<F8>',
F9 = '<F9>',
F10 = '<F10>',
F11 = '<F11>',
F12 = '<F12>',
},
},
})
-- Document existing key chains
require('which-key').add({
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
})
end,
}