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]
enabled = false

View File

@ -1,7 +1,7 @@
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.expandtab = true
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
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
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',
noremap = true,
silent = true
})
silent = true,
}
)
-- Keybinding to view the compiled PDF in Zathura from the output directory
vim.keymap.set('n', '<leader>lv', function()
local pdf_path = vim.fn.expand('%:p:h') .. '/output/' .. vim.fn.expand('%:t:r') .. '.pdf'
vim.cmd(':silent !nohup zathura ' .. pdf_path .. ' >/dev/null 2>&1 &')
local pdf_path = vim.fn.expand('%:p:h/output/%:t:r.pdf')
-- 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, {
desc = 'View PDF in Zathura from the output directory',
noremap = true,
silent = true
silent = true,
})
-- Custom surroundings for LaTeX
vim.g.surround_110 = "\\begin{\r}\n\\end{\r}" -- map `yssn` for \begin{} \end{}
-- Function to close the Zathura instance for the current PDF
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
vim.cmd [[
vim.cmd([[
augroup FormatOnSave
autocmd!
autocmd BufWritePre * lua vim.lsp.buf.format({ async = false })
augroup END
]]
]])
-- Augroup for Highlight on yank
vim.cmd([[
@ -63,30 +63,3 @@ vim.cmd([[
autocmd TermOpen * normal! G
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', '<leader>pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" })
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
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', '<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', 'n', 'nzzzv', { silent = true })
vim.keymap.set('n', 'N', 'Nzzzv', { silent = true })
vim.keymap.set('n', 'n', 'nzzzv', { noremap = true, 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.keymap.set('n', '<C-k>', '<cmd>cnext<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" })
-- 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" })

View File

@ -54,6 +54,15 @@ local opts = {
termguicolors = true,
scrolloff = 10,
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
@ -116,12 +125,11 @@ end
opt.formatoptions = 'l'
opt.formatoptions = opt.formatoptions
- 'a' -- Auto formatting is BAD.
- 't' -- Don't auto format my code. I got linters for that.
+ 'c' -- In general, I like it when comments respect textwidth
- 'o' -- O and o, don't continue comments
+ 'r' -- But do continue when pressing enter.
+ 'n' -- Indent past the formatlistpat, not underneath it.
+ 'j' -- Auto-remove comments if possible.
- '2' -- I'm not in gradeschool anymore
- 'a' -- Auto formatting is BAD.
- 't' -- Don't auto format my code. I got linters for that.
+ 'c' -- In general, I like it when comments respect textwidth
- 'o' -- O and o, don't continue comments
+ 'r' -- But do continue when pressing enter.
+ 'n' -- Indent past the formatlistpat, not underneath it.
+ 'j' -- Auto-remove comments if possible.
- '2' -- I'm not in gradeschool anymore

View File

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

View File

@ -3,29 +3,64 @@ return {
'hrsh7th/nvim-cmp',
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
{ 'L3MON4D3/LuaSnip', lazy = true },
{ 'saadparwaiz1/cmp_luasnip', lazy = true },
-- Adds LSP completion capabilities
'hrsh7th/cmp-nvim-lsp',
{ 'hrsh7th/cmp-nvim-lsp' },
-- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets',
{ 'rafamadriz/friendly-snippets', lazy = true },
-- Optional sources
'hrsh7th/cmp-path',
'hrsh7th/cmp-buffer',
-- Optional sources for path and buffer completion
{ 'hrsh7th/cmp-path', lazy = true },
{ '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' },
config = function()
local cmp = require('cmp')
local luasnip = require('luasnip')
local lspkind = require('lspkind')
-- Set completion options
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
-- Import required modules
local cmp = require('cmp')
local luasnip = require('luasnip')
local cmp_mappings = {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), -- Trigger completion
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Confirm selection
['<C-l>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
['<C-e>'] = cmp.mapping.abort(), -- Abort completion
}
-- Setup luasnip
-- Setup LuaSnip configuration
luasnip.config.setup({
history = true,
updateevents = 'TextChanged,TextChangedI',
@ -39,59 +74,34 @@ return {
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
luasnip.lsp_expand(args.body) -- Expand snippets
end,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'nvim_lsp' }, -- LSP completions
{ name = 'luasnip' }, -- Snippet completions
{ name = 'path' }, -- Path completions
{ name = 'buffer' }, -- Buffer completions
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
completion = cmp.config.window.bordered(), -- Border for completion window
documentation = cmp.config.window.bordered(), -- Border for documentation window
},
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,
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({
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-l>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
['<C-e>'] = cmp.mapping.abort(),
}),
mapping = cmp.mapping.preset.insert(cmp_mappings),
})
-- Setup for SQL filetype with vim-dadbod-completion
@ -101,6 +111,36 @@ return {
{ 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,
}

View File

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

View File

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

View File

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

View File

@ -1,16 +1,16 @@
return {
-- Add the nvim-dap related plugins
-- add the nvim-dap related plugins
{
'mfussenegger/nvim-dap',
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' },
{ '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' },
{ 'leoluz/nvim-dap-go', opt = true, ft = 'go' },
{ 'simrat39/rust-tools.nvim', opt = true, ft = 'rust' },
'williamboman/mason.nvim', -- Mason for managing external tools
'williamboman/mason-lspconfig.nvim'
'williamboman/mason.nvim', -- mason for managing external tools
'williamboman/mason-lspconfig.nvim',
},
config = function()
local dap = require('dap')
@ -18,26 +18,16 @@ return {
local dap_virtual_text = require('nvim-dap-virtual-text')
local mason_registry = require('mason-registry')
-- Initialize dap-ui
-- initialize dap-ui
dapui.setup()
-- Initialize dap-virtual-text
-- initialize dap-virtual-text
dap_virtual_text.setup()
-- Keybindings
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
-- dap python
local function get_python_path()
local cwd = vim.fn.getcwd()
if vim.env.VIRTUAL_ENV then
return vim.env.VIRTUAL_ENV .. '/bin/python'
if vim.env.virtual_env then
return vim.env.virtual_env .. '/bin/python'
elseif vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
return cwd .. '/venv/bin/python'
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
@ -49,13 +39,13 @@ return {
require('dap-python').setup(get_python_path())
-- DAP Go
-- dap go
require('dap-go').setup()
-- DAP Rust
-- dap rust
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_path = codelldb_package:get_install_path()
local codelldb_adapter = codelldb_path .. '/extension/adapter/codelldb'
@ -63,55 +53,121 @@ return {
rust_tools.setup({
tools = {
autoSetHints = true,
autosethints = true,
inlay_hints = {
show_parameter_hints = true,
parameter_hints_prefix = "<- ",
other_hints_prefix = "=> ",
parameter_hints_prefix = '<- ',
other_hints_prefix = '=> ',
},
},
server = {
on_attach = function(_, bufnr)
-- DAP Rust keymaps
vim.api.nvim_buf_set_keymap(bufnr, '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 })
-- dap rust keymaps
vim.api.nvim_buf_set_keymap(
bufnr,
'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,
},
dap = {
adapter = require('rust-tools.dap').get_codelldb_adapter(
codelldb_adapter,
codelldb_lib
),
adapter = require('rust-tools.dap').get_codelldb_adapter(codelldb_adapter, codelldb_lib),
},
})
-- DAP UI integration
dap.listeners.after.event_initialized["dapui_config"] = function()
-- dap ui integration
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close()
end
-- Define signs for breakpoints
vim.fn.sign_define('DapBreakpoint', { text = '🔴', texthl = '', linehl = '', numhl = '' })
vim.fn.sign_define('DapStopped', { text = '🟢', texthl = '', linehl = '', numhl = '' })
-- define signs for breakpoints
vim.fn.sign_define('dapbreakpoint', { text = '🔴', texthl = '', linehl = '', numhl = '' })
vim.fn.sign_define('dapstopped', { text = '🟢', texthl = '', linehl = '', numhl = '' })
end,
keys = {
{ 'n', '<leader>dc', ':lua require"dap".continue()<CR>' },
{ 'n', '<leader>ds', ':lua require"dap".step_over()<CR>' },
{ 'n', '<leader>di', ':lua require"dap".step_into()<CR>' },
{ 'n', '<leader>do', ':lua require"dap".step_out()<CR>' },
{ 'n', '<leader>db', ':lua require"dap".toggle_breakpoint()<CR>' },
{ 'n', '<leader>dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))<CR>' },
{ 'n', '<leader>dr', ':lua require"dap".repl.open()<CR>' },
{ 'n', '<leader>du', ':lua require"dapui".toggle()<CR>' }
{
'<leader>dc',
function()
require('dap').continue()
end,
mode = 'n',
noremap = true,
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',
},
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()
local formatters_by_ft = {
lua = { 'stylua' },
@ -16,33 +27,38 @@ return {
end
end,
go = { 'gofumpt', 'goimports' },
yaml = { 'prettier' }, -- Added YAML formatter
bash = { 'shfmt' }, -- Added Bash formatter
rust = { 'rustfmt' }, -- Added Rust formatter
dockerfile = { 'hadolint' }, -- Added Dockerfile formatter
yaml = { 'prettier' },
bash = { 'shfmt' },
rust = { 'rustfmt' },
dockerfile = { 'hadolint' },
}
require('conform').setup({
return {
notify_on_error = false,
format_on_save = function(bufnr)
local disable_filetypes = { c = true, cpp = true }
return {
timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
}
end,
formatters_by_ft = formatters_by_ft,
format_on_save = {
lsp_fallback = true,
timeout_ms = 500,
},
})
}
end,
config = function(_, opts)
require('conform').setup(opts)
require('mason-tool-installer').setup({
ensure_installed = {
'stylua', -- Lua
'ruff', -- Python
'isort', -- Python
'black', -- Python
'gofumpt', -- Go
'goimports', -- Go
'prettier', -- YAML, JSON, etc.
'shfmt', -- Bash
'hadolint', -- Dockerfile
'stylua',
'ruff',
'isort',
'black',
'gofumpt',
'goimports',
'shfmt',
'hadolint',
},
})
end,
}

View File

@ -14,7 +14,8 @@ return {
-- on_attach function executed when the plugin is attached to a buffer
on_attach = function(bufnr)
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
@ -42,4 +43,3 @@ return {
},
},
}

View File

@ -12,9 +12,10 @@ return {
go = { 'golangcilint' },
yaml = { 'yamllint' },
bash = { 'shellcheck' },
lua = { 'luacheck' }, -- Added Lua linter
rust = { 'clippy' }, -- Use `clippy` for Rust linting
lua = { 'luacheck' }, -- Added Lua linter
rust = { 'clippy' }, -- Use `clippy` for Rust linting
dockerfile = { 'hadolint' }, -- Added Dockerfile linter
-- rust = { 'clippy' }, -- Use `clippy` for Rust linting
}
-- Autocommand group for triggering linting
@ -36,15 +37,15 @@ return {
-- Mason tool installer setup
require('mason-tool-installer').setup({
ensure_installed = {
'ruff', -- Python
-- 'clippy', -- Rust
'ruff', -- Python
-- 'mypy', -- Uncomment if needed for additional Python linting
'golangci-lint', -- Go
'yamllint', -- YAML
'shellcheck', -- Bash
'luacheck', -- Lua
'hadolint', -- Dockerfile
'yamllint', -- YAML
'shellcheck', -- Bash
'luacheck', -- Lua
'hadolint', -- Dockerfile
},
})
end,
}

View File

@ -10,6 +10,7 @@ return {
'j-hui/fidget.nvim',
tag = 'legacy',
opts = {},
event = 'LspAttach', -- Lazy load on LSP attachment
},
-- 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 = {
flags = {
debounce_text_changes = 150,
@ -62,13 +65,13 @@ return {
settings = {
texlab = {
build = {
executable = "latexmk",
args = { "-pdf", "-xelatex", "-output-directory=output", "-interaction=nonstopmode", "-synctex=1", "%f" },
executable = 'latexmk',
args = { '-pdf', '-xelatex', '-output-directory=output', '-interaction=nonstopmode', '-synctex=1', '%f' },
onSave = true,
},
forwardSearch = {
executable = "zathura",
args = { "--synctex-forward", "%l:1:%f", "%p" },
executable = 'zathura',
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 = {
filetypes = { 'yaml' },
settings = {
@ -156,11 +166,12 @@ return {
spacing = 2,
},
float = {
Source = 'if_many',
source = 'if_many',
border = 'rounded',
},
})
-- Define diagnostic signs
local sign = function(opts)
vim.fn.sign_define(opts.name, {
texthl = opts.name,
@ -174,10 +185,8 @@ return {
sign({ name = 'DiagnosticSignHint', text = '' })
sign({ name = 'DiagnosticSignInfo', text = '»' })
-- Fidget configuration (LSP progress)
require('fidget').setup({})
-- Neodev setup for improved Lua development
require('fidget').setup({})
require('neodev').setup({
library = {
plugins = { 'nvim-dap-ui' },
@ -186,4 +195,3 @@ return {
})
end,
}

View File

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

View File

@ -5,8 +5,20 @@ return {
'L3MON4D3/LuaSnip',
},
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()
require('neogen').setup({
@ -16,4 +28,3 @@ return {
-- Uncomment next line if you want to follow only stable versions
-- version = "*"
}

View File

@ -1,8 +1,7 @@
return {
'shaunsingh/solarized.nvim',
event = "VeryLazy",
event = 'VeryLazy',
config = function()
vim.g.solarized_variant = 'light'
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 {
'folke/which-key.nvim',
event = 'VimEnter',
opts = {
plugins = {
marks = true,
registers = true,
spelling = {
enabled = true,
suggestions = 20,
},
},
windows = {
border = 'single',
},
},
}
-- return {
-- 'folke/which-key.nvim',
-- event = 'VimEnter',
-- opts = {
-- plugins = {
-- marks = true,
-- registers = true,
-- spelling = {
-- enabled = true,
-- suggestions = 20,
-- },
-- },
-- windows = {
-- 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,
}