2023-07-14 16:21:54 -04:00
-- theming
-- Default options
2023-09-04 10:14:39 -04:00
vim.opt . termguicolors = true
vim.cmd . colorscheme ' duskfox '
2023-07-14 16:21:54 -04:00
2023-07-20 10:48:23 -04:00
-- turn on relative line numbers
vim.opt . relativenumber = true
2023-08-14 11:43:36 -04:00
vim.opt . number = true
2023-09-21 09:38:23 -04:00
vim.opt . expandtab = true
vim.opt . paste = false
vim.opt . autoindent = true
vim.opt . linebreak = true
2023-09-22 11:06:02 -04:00
vim.opt . mouse = " "
2023-10-28 09:18:46 -04:00
-- neovim tabstop and shift behavior got more complicated.
-- This should cover all the cases though
2023-09-21 09:38:23 -04:00
vim.opt . tabstop = 4
2023-10-28 09:18:46 -04:00
vim.opt . shiftwidth = 4
--vim.opt.smarttab = false
2024-10-02 07:43:52 -05:00
vim.opt . fileformats = " unix,dos "
2025-05-05 11:36:52 -04:00
-- Recommended by Avante docs
-- views can only be fully collapsed with the global statusline
vim.opt . laststatus = 3
2023-08-17 15:34:36 -04:00
2023-08-18 16:57:12 -04:00
vim.g . BASH_AuthorName = ' Jeremy Wall '
vim.g . BASH_AuthorRef = ' jw '
vim.g . BASH_Email = ' jeremy@marzhillstudios.com '
-- We want to use a different leader key
vim.g . mapleader = ' , '
2023-08-17 15:34:36 -04:00
vim.cmd ( " noswapfile " )
vim.cmd ( " syntax on " )
vim.cmd ( " filetype plugin on " )
2025-05-08 19:50:57 -04:00
vim.api . nvim_create_autocmd ( { " BufEnter " , " BufWinEnter " } , {
pattern = { " *.qnt " } ,
callback = function ( args )
2024-09-15 20:47:48 -04:00
vim.lsp . start ( {
name = ' quint ' ,
2025-05-08 19:50:57 -04:00
cmd = { ' quint-language-server ' , ' --stdio ' } ,
2024-09-15 20:47:48 -04:00
root_dir = vim.fs . dirname ( vim.uri_from_bufnr ( args.buf ) )
} )
2025-05-08 19:50:57 -04:00
end ,
2024-09-15 20:47:48 -04:00
} )
2025-05-28 18:37:58 -04:00
vim.api . nvim_create_autocmd ( { " BufNewfile " , " BufRead " } , {
callback = function ( args )
-- If treesitter supports this filetype then use the treesitter fold expression
local ft = vim.bo . filetype
if ft and ft ~= " " then
-- Safely check if a parser exists for this filetype
local has_parser = pcall ( function ( ) return vim.treesitter . language.inspect ( ft ) end )
if has_parser then
vim.wo . foldexpr = ' v:lua.vim.treesitter.foldexpr() '
vim.wo . foldmethod = ' expr '
2025-06-05 08:42:10 -04:00
vim.wo . foldlevel = 10
2025-05-28 18:37:58 -04:00
end
end
end ,
} )
2023-08-17 15:34:36 -04:00
vim.cmd ( [ [
au BufNewFile , BufRead * Makefile , * . mk set noexpandtab
] ] )
vim.cmd ( [ [
au BufNewFile , BufRead * . py , * . java set tabstop = 2
] ] )
vim.cmd ( [ [
au BufNewFile , BufRead * . app set filetype = erlang
] ] )
2023-10-28 09:18:46 -04:00
vim.cmd ( [ [
au BufNewFile , BufRead * . tf set filetype = terraform
] ] )
2023-11-22 18:08:31 -05:00
vim.cmd ( [ [
au BufNewFile , BufRead * . hcl , * . hcl2 set filetype = hcl
] ] )
2023-08-17 15:34:36 -04:00
vim.cmd ( [ [
au BufNewFile , BufRead . bash_ * set filetype = sh
] ] )
vim.cmd ( [ [
au BufNewFile , BufRead * . erl filetype indent off
] ] )
vim.cmd ( [ [
au BufNewFile , BufRead * . hrl filetype indent off
] ] )
2023-07-20 10:48:23 -04:00
2024-10-09 19:26:27 -04:00
vim.cmd ( [ [
2025-05-08 19:50:57 -04:00
au BufNewFile , BufRead * . nix set tabstop = 2 nosmarttab
2024-10-09 19:26:27 -04:00
] ] )
vim.cmd ( [ [
au BufNewFile , BufRead * . ebnf set filetype = ebnf
] ] )
2023-09-22 11:06:02 -04:00
2024-08-26 19:58:11 -04:00
-- Telelscope Imports
local telescope = require ( ' telescope ' )
local telescope_builtins = require ( ' telescope.builtin ' )
local telescope_actions = require ( ' telescope.actions ' )
2023-07-24 15:42:28 -04:00
--
2023-07-14 16:21:54 -04:00
--https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
2023-07-24 15:42:28 -04:00
-- TODO(jwall): See about proper snippet support (ie. license comments?)
local cmp = require ( ' cmp ' )
cmp.setup ( {
2024-01-06 11:06:05 -05:00
-- Enable LSP snippets
snippet = {
expand = function ( args )
vim.fn [ " vsnip#anonymous " ] ( args.body )
end ,
} ,
mapping = cmp.mapping . preset.insert {
[ ' <C-k> ' ] = cmp.mapping . select_prev_item ( ) ,
[ ' <C-j> ' ] = cmp.mapping . select_next_item ( ) ,
[ ' <C-d> ' ] = cmp.mapping . scroll_docs ( - 4 ) ,
[ ' <C-f> ' ] = cmp.mapping . scroll_docs ( 4 ) ,
[ ' <CR> ' ] = cmp.mapping . confirm {
behavior = cmp.ConfirmBehavior . Replace ,
select = true ,
} ,
} ,
-- Installed sources:
sources = cmp.config . sources (
{
{ name = ' nvim_lsp ' , keyword_length = 3 } , -- from language server
2024-01-31 20:52:11 -05:00
{ name = ' nvim_lsp_signature_help ' } , -- display function signatures with current parameter emphasized
2024-01-06 11:06:05 -05:00
} ,
{
{ name = ' path ' } , -- file paths
} ,
{
{ name = ' nvim_lua ' , keyword_length = 2 } , -- complete neovim's Lua runtime API such vim.lsp.*
{ name = ' buffer ' , keyword_length = 2 } , -- source current buffer
{ name = ' vsnip ' , keyword_length = 2 } , -- nvim-cmp source for vim-vsnip
} ) ,
window = {
completion = cmp.config . window.bordered ( ) ,
documentation = cmp.config . window.bordered ( ) ,
2023-09-04 10:14:39 -04:00
} ,
2023-07-24 15:42:28 -04:00
} )
2023-07-14 16:21:54 -04:00
2023-09-11 16:39:59 -04:00
-- logging
--vim.lsp.set_log_level('trace')
--vim.lsp.log.set_format_func(vim.inspect)
local caps = vim.tbl_deep_extend (
2024-01-06 11:06:05 -05:00
' force ' ,
vim.lsp . protocol.make_client_capabilities ( ) ,
require ( ' cmp_nvim_lsp ' ) . default_capabilities ( ) ,
-- File watching is disabled by default for neovim.
-- See: https://github.com/neovim/neovim/pull/22405
{ workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } } ,
{ window = { progress = false } }
2023-09-11 16:39:59 -04:00
) ;
2024-01-09 08:30:42 -05:00
2023-07-20 10:48:23 -04:00
local lspconfig = require ( " lspconfig " )
2023-07-24 15:42:28 -04:00
2024-10-11 16:09:08 -04:00
-- Typst
2025-05-08 19:50:57 -04:00
lspconfig.tinymist . setup {
2024-10-11 16:09:08 -04:00
capabilities = caps ,
settings = {
exportPdf = " onSave " ,
} ,
}
2023-10-28 09:18:46 -04:00
-- Terraform lsp setup
2024-01-06 11:06:05 -05:00
lspconfig.terraformls . setup { }
2023-10-28 09:18:46 -04:00
2023-07-14 16:21:54 -04:00
-- Nix language server support
2024-01-06 11:06:05 -05:00
lspconfig.nil_ls . setup {
2023-09-11 16:39:59 -04:00
capabilities = caps ,
}
2023-07-14 16:21:54 -04:00
2025-05-08 19:50:57 -04:00
lspconfig.jedi_language_server . setup { }
2025-04-22 14:40:12 -04:00
2024-05-16 11:45:45 -05:00
require ( ' roslyn ' ) . setup ( {
2024-10-11 16:09:08 -04:00
-- client, bufnr
2025-05-08 19:50:57 -04:00
on_attach = function ( _ , _ )
2024-05-16 11:45:45 -05:00
--vim.notify(vim.inspect(client))
end ,
2024-05-17 09:31:58 -05:00
sdk_framework = " net8.0 " ,
2024-05-16 11:45:45 -05:00
capabilities = caps ,
log_level = " Trace " ,
} ) ;
2024-01-09 08:30:42 -05:00
2023-07-30 15:15:42 -04:00
--ocaml
2024-01-06 11:06:05 -05:00
lspconfig.ocamllsp . setup {
2023-09-11 16:39:59 -04:00
capabilities = caps
2023-09-04 10:14:39 -04:00
}
2023-07-30 15:15:42 -04:00
2023-07-14 16:21:54 -04:00
-- Java language server support
2024-01-06 11:06:05 -05:00
lspconfig.java_language_server . setup {
2023-09-11 16:39:59 -04:00
capabilities = caps
2023-09-04 10:14:39 -04:00
}
2023-07-14 16:21:54 -04:00
-- Typescript language server support
2024-01-06 11:06:05 -05:00
lspconfig.tsserver . setup {
2023-09-11 16:39:59 -04:00
capabilities = caps
2023-09-04 10:14:39 -04:00
}
2023-07-14 16:21:54 -04:00
2023-07-16 22:21:45 -04:00
-- Rust language server support
2024-01-06 11:06:05 -05:00
lspconfig.rust_analyzer . setup {
2024-01-22 15:53:22 -05:00
settings = {
-- https://github.com/rust-lang/rust-analyzer/blob/master/docs/user/generated_config.adoc
2024-01-31 20:52:11 -05:00
[ ' rust-analyzer ' ] = {
cargo = { features = " all " }
}
2024-01-22 15:53:22 -05:00
} ,
2023-09-11 16:39:59 -04:00
capabilities = caps
2023-07-24 15:42:28 -04:00
}
2023-07-20 10:48:23 -04:00
-- lua language server setup.
2024-01-06 11:06:05 -05:00
lspconfig.lua_ls . setup {
settings = {
Lua = {
runtime = { version = ' LuaJIT ' , } ,
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { ' vim ' } ,
} ,
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api . nvim_get_runtime_file ( " " , true ) ,
-- Disable the checkThirdParty prompts.
checkThirdParty = false ,
} ,
telemetry = {
enable = false ,
} ,
2023-08-23 18:46:02 -04:00
} ,
2024-01-06 11:06:05 -05:00
} ,
2023-09-11 16:39:59 -04:00
capabilities = caps
2023-08-23 18:46:02 -04:00
}
2023-07-16 22:21:45 -04:00
-- lsp configuration
2023-07-14 16:21:54 -04:00
vim.api . nvim_create_autocmd ( ' LspAttach ' , {
2024-01-06 11:06:05 -05:00
callback = function ( args )
local opts = { buffer = args.buf }
vim.keymap . set ( " n " , ' <C-Space> ' , function ( )
vim.lsp . buf.hover ( )
end , opts )
vim.keymap . set ( { " n " , " v " } , " <Leader>a " , vim.lsp . buf.code_action , opts )
vim.keymap . set ( " n " , " <Leader>f " , vim.lsp . buf.format , opts )
local client = vim.lsp . get_client_by_id ( args.data . client_id )
2025-05-08 19:50:57 -04:00
---@diagnostic disable-next-line: undefined-field
2024-08-26 16:57:47 -04:00
if client and client.server_capabilities . codelens then
2024-01-06 11:06:05 -05:00
vim.lsp . codelens.refresh ( )
end
end ,
2023-07-14 16:21:54 -04:00
} )
2024-01-06 11:06:05 -05:00
vim.api . nvim_create_autocmd ( { ' BufEnter ' , ' InsertLeave ' , ' CursorHold ' } , {
2024-08-26 16:57:47 -04:00
callback = function ( args )
2025-05-08 19:50:57 -04:00
local clients = vim.lsp . get_clients ( { bufnr = args.buf } )
2023-09-11 16:39:59 -04:00
for cid = 1 , # clients do
2025-05-08 19:50:57 -04:00
---@diagnostic disable-next-line: undefined-field
2023-09-11 16:39:59 -04:00
if clients [ cid ] . server_capabilities.codelens then
vim.lsp . codelens.refresh ( )
break
2023-08-28 14:08:20 -04:00
end
2023-08-22 17:53:41 -04:00
end
end ,
} )
2024-01-06 11:06:05 -05:00
-- LSP Diagnostics Options Setup
2023-07-14 16:21:54 -04:00
local sign = function ( opts )
2024-01-06 11:06:05 -05:00
vim.fn . sign_define ( opts.name , {
texthl = opts.name ,
text = opts.text ,
numhl = ' '
} )
2023-07-14 16:21:54 -04:00
end
2024-01-06 11:06:05 -05:00
sign ( { name = ' DiagnosticSignError ' , text = ' 🔥 ' } )
sign ( { name = ' DiagnosticSignWarn ' , text = ' ⚠️ ' } )
sign ( { name = ' DiagnosticSignHint ' , text = ' ➡️ ' } )
sign ( { name = ' DiagnosticSignInfo ' , text = ' 🗒️ ' } )
2023-07-14 16:21:54 -04:00
vim.diagnostic . config ( {
virtual_text = false ,
signs = true ,
update_in_insert = true ,
underline = true ,
severity_sort = false ,
float = {
border = ' rounded ' ,
2024-08-26 16:57:47 -04:00
source = true ,
2023-07-14 16:21:54 -04:00
header = ' ' ,
prefix = ' ' ,
} ,
} )
vim.cmd ( [ [
set signcolumn = yes
autocmd CursorHold * lua vim.diagnostic . open_float ( nil , { focusable = false } )
] ] )
--Set completeopt to have a better completion experience
-- :help completeopt
-- menuone: popup even when there's only one match
-- noinsert: Do not insert text until a selection is made
-- noselect: Do not select, force to select one from the menu
-- shortness: avoid showing extra messages when using completion
-- updatetime: set updatetime for CursorHold
2024-01-06 11:06:05 -05:00
vim.opt . completeopt = { ' menuone ' , ' noselect ' , ' noinsert ' }
vim.opt . shortmess = vim.opt . shortmess + { c = true }
2024-08-26 16:57:47 -04:00
vim.api . nvim_set_option_value ( ' updatetime ' , 300 , { scope = " global " } )
2024-01-06 11:06:05 -05:00
vim.opt . sessionoptions = { ' buffers ' , ' curdir ' , ' skiprtp ' , ' localoptions ' , ' terminal ' , ' tabpages ' }
2023-07-14 16:21:54 -04:00
-- Fixed column for diagnostics to appear
-- Show autodiagnostic popup on cursor hover_range
2024-01-06 11:06:05 -05:00
-- Goto previous / next diagnostic warning / error
-- Show inlay_hints more frequently
2023-07-14 16:21:54 -04:00
vim.cmd ( [ [
set signcolumn = yes
autocmd CursorHold * lua vim.diagnostic . open_float ( nil , { focusable = false } )
] ] )
2024-01-06 11:06:05 -05:00
-- Treesitter Plugin Setup
2023-10-28 09:18:46 -04:00
2023-07-14 16:21:54 -04:00
require ( ' nvim-treesitter.configs ' ) . setup {
2024-01-06 11:06:05 -05:00
highlight = {
enable = true ,
additional_vim_regex_highlighting = false ,
} ,
2024-03-03 15:21:50 -05:00
indent = { enable = true } ,
2024-01-06 11:06:05 -05:00
rainbow = {
enable = true ,
extended_mode = true ,
max_file_lines = nil ,
} ,
2025-05-28 18:37:58 -04:00
textobjects = { enable = true } ,
2025-05-28 17:46:58 -04:00
incremental_selection = {
enable = true ,
keymaps = {
init_selection = ' <Leader>c ' ,
node_incremental = ' <Leader>c ' ,
scope_incremental = ' <Leader>ci ' ,
node_decremental = ' <Leader>cx ' ,
} ,
} ,
2023-08-22 17:53:41 -04:00
}
2024-01-06 11:06:05 -05:00
require ' treesitter-context ' . setup {
2024-01-31 20:52:11 -05:00
enable = true , -- Enable this plugin (Can be enabled/disabled later via commands)
max_lines = 5 , -- How many lines the window should span. Values <= 0 mean no limit.
min_window_height = 45 , -- Minimum editor window height to enable context. Values <= 0 mean no limit.
2024-01-06 11:06:05 -05:00
line_numbers = true ,
multiline_threshold = 20 , -- Maximum number of lines to collapse for a single context line
2024-01-31 20:52:11 -05:00
trim_scope = ' outer ' , -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
mode = ' cursor ' , -- Line used to calculate context. Choices: 'cursor', 'topline'
2024-01-06 11:06:05 -05:00
-- Separator between context and content. Should be a single character string, like '-'.
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
separator = nil ,
2024-01-31 20:52:11 -05:00
zindex = 20 , -- The Z-index of the context window
2024-01-06 11:06:05 -05:00
on_attach = nil , -- (fun(buf: integer): boolean) return false to disable attaching
2023-07-14 16:21:54 -04:00
}
vim.g . loaded_netrw = 1
vim.g . loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups
vim.opt . termguicolors = true
2023-07-16 22:21:45 -04:00
-- setup nvim-tree
2024-01-06 11:06:05 -05:00
require ( " nvim-tree " ) . setup {
2023-07-19 18:58:36 -04:00
hijack_unnamed_buffer_when_opening = true ,
update_focused_file = {
enable = true ,
} ,
renderer = {
2024-01-06 11:06:05 -05:00
icons = {
2023-07-19 18:58:36 -04:00
show = {
file = false ,
} ,
glyphs = {
2024-01-06 11:06:05 -05:00
default = " - " ,
2023-07-19 18:58:36 -04:00
symlink = " S " ,
2024-01-06 11:06:05 -05:00
bookmark = " 🎗 " ,
modified = " ● " ,
folder = {
arrow_closed = " → " ,
arrow_open = " ↓ " ,
default = " 📁 " ,
open = " 📂 " ,
empty = " 📁 " ,
empty_open = " 📂 " ,
symlink = " S " ,
symlink_open = " S " ,
} ,
git = {
unstaged = " ✗ " ,
staged = " ✓ " ,
unmerged = " ∦ " ,
renamed = " ➜ " ,
untracked = " ★ " ,
deleted = " X " ,
ignored = " ◌ " ,
} ,
2023-07-19 18:58:36 -04:00
} ,
2024-01-06 11:06:05 -05:00
} ,
2023-09-15 16:44:38 -04:00
} ,
2023-07-19 18:58:36 -04:00
diagnostics = {
enable = true ,
show_on_dirs = true ,
icons = {
hint = " ➡️ " ,
info = " 🗒️ " ,
warning = " ⚠️ " ,
error = " 🔥 " ,
} ,
} ,
}
2023-07-16 21:20:15 -04:00
2024-01-06 11:06:05 -05:00
require ( ' trouble ' ) . setup {
2023-07-20 10:48:23 -04:00
icons = false ,
signs = {
hint = " ➡️ " ,
information = " 🗒️ " ,
warning = " ⚠️ " ,
error = " 🔥 " ,
other = " ? " ,
} ,
}
2023-07-16 21:20:15 -04:00
vim.keymap . set ( " n " , " <C-p> " , function ( )
require ( " nvim-tree.api " ) . tree.toggle ( )
end )
2023-07-16 22:21:45 -04:00
2023-07-20 14:09:01 -04:00
vim.keymap . set ( " n " , " <Leader>tc " , function ( )
vim.cmd ( " tabclose " )
end )
2023-07-25 14:37:23 -04:00
vim.keymap . set ( " n " , " <Leader>tn " , function ( )
vim.cmd ( " tabnew " )
end )
vim.keymap . set ( " n " , " <Leader>tk " , function ( )
2023-08-03 08:23:16 -04:00
vim.cmd ( " tabnext " )
2023-07-25 14:37:23 -04:00
end )
vim.keymap . set ( " n " , " <Leader>tj " , function ( )
vim.cmd ( " tabprev " )
end )
2023-07-20 14:09:01 -04:00
vim.keymap . set ( " n " , " <Leader>ts " , function ( )
vim.cmd ( " tabs " )
2023-07-18 21:53:44 -04:00
end )
2024-03-12 10:11:14 -04:00
-- Neogit integration
-- See https://github.com/NeogitOrg/neogit for configuration information.
local neogit = require ( ' neogit ' )
2024-08-26 16:57:47 -04:00
neogit.setup { }
2024-03-12 10:11:14 -04:00
2023-07-31 10:34:26 -04:00
vim.keymap . set ( " n " , " <Leader>mg " , function ( )
2024-03-12 10:11:14 -04:00
neogit.open ( )
2023-07-31 10:34:26 -04:00
end )
2024-03-06 12:08:27 -05:00
-- Add a file to git
vim.keymap . set ( " n " , " <Leader>ga " , function ( )
vim.cmd ( " !git add % " )
end )
2024-01-06 11:06:05 -05:00
require ( ' possession ' ) . setup {
2023-09-11 10:26:01 -04:00
commands = {
save = ' SSave ' ,
load = ' SLoad ' ,
delete = ' SDelete ' ,
list = ' SList ' ,
} ,
autosave = {
current = true ,
on_load = true ,
on_quit = true ,
} ,
telescope = {
list = {
default_action = ' load ' ,
mappings = {
save = { n = ' <c-x> ' , i = ' <c-x> ' } ,
load = { n = ' <c-v> ' , i = ' <c-v> ' } ,
delete = { n = ' <c-t> ' , i = ' <c-t> ' } ,
rename = { n = ' <c-r> ' , i = ' <c-r> ' } ,
} ,
} ,
} ,
}
2023-08-04 15:41:25 -04:00
2023-09-11 10:26:01 -04:00
telescope.load_extension ( ' possession ' )
2024-01-06 11:06:05 -05:00
-- https://github.com/nvim-telescope/telescope.nvim
2023-08-14 11:43:36 -04:00
telescope.setup ( {
2024-01-06 11:06:05 -05:00
defaults = {
initial_mode = " normal " ,
2023-08-28 14:08:20 -04:00
mappings = {
2024-01-06 11:06:05 -05:00
n = {
[ " <Leader>ql " ] = telescope_actions.send_selected_to_qflist + telescope_actions.open_qflist ,
} ,
2023-08-28 14:08:20 -04:00
} ,
2024-01-06 11:06:05 -05:00
} ,
2024-04-17 14:12:26 -04:00
pickers = {
buffers = {
mappings = {
n = {
[ " <c-d> " ] = telescope_actions.delete_buffer
} ,
} ,
} ,
} ,
2023-08-14 11:43:36 -04:00
} )
2023-08-04 15:41:25 -04:00
2023-12-08 18:03:17 -05:00
local harpoon = require ( ' harpoon ' )
harpoon : setup ( )
2024-01-31 20:52:04 -05:00
local lean = require ' lean '
lean.setup {
lsp = {
2024-10-11 16:09:08 -04:00
-- client, bufnr
on_attach = function ( _ , bufnr )
2024-01-31 20:52:04 -05:00
local opts = { buffer = bufnr }
vim.keymap . set ( { " n " , " v " } , " <Leader>ti " , function ( ) vim.cmd ( " LeanInfoviewToggle " ) end , opts )
vim.keymap . set ( { " n " , " v " } , " <Leader>sg " , function ( ) vim.cmd ( " LeanGoal " ) end , opts )
vim.keymap . set ( { " n " , " v " } , " <Leader>stg " , function ( ) vim.cmd ( " LeanTermGoal " ) end , opts )
2025-05-08 19:50:57 -04:00
vim.api . nvim_set_option_value ( ' omnifunc ' , ' v:lua.vim.lsp.omnifunc ' , { scope = " local " , buf = bufnr } )
2024-01-31 20:52:04 -05:00
end
} ,
mappings = true ,
2024-01-29 21:49:43 -05:00
}
2024-01-05 16:34:03 -05:00
-- telescope keymaps
vim.keymap . set ( " n " , " <Leader>pl " , telescope.extensions . possession.list )
2024-03-12 10:11:14 -04:00
-- TODO(zaphar): Remove this once my muscle memory has set in.
2023-08-04 15:41:25 -04:00
vim.keymap . set ( " n " , " <Leader>nff " , telescope_builtins.fd )
2024-03-12 10:11:14 -04:00
vim.keymap . set ( " n " , " <Leader>ff " , telescope_builtins.fd )
2023-08-14 11:43:36 -04:00
vim.keymap . set ( " n " , " <Leader>rl " , telescope_builtins.lsp_references )
2023-08-17 15:34:36 -04:00
vim.keymap . set ( " n " , " <Leader>rn " , vim.lsp . buf.rename )
2023-08-14 11:43:36 -04:00
vim.keymap . set ( " n " , " <Leader>sl " , telescope_builtins.lsp_workspace_symbols )
2023-08-17 15:34:36 -04:00
vim.keymap . set ( " n " , " <Leader>dl " , telescope_builtins.diagnostics )
2023-08-18 16:57:35 -04:00
vim.keymap . set ( " n " , " <Leader>rg " , telescope_builtins.live_grep )
2025-05-08 19:50:57 -04:00
vim.keymap . set ( " n " , " <Leader>bl " , function ( )
telescope_builtins.buffers ( {
} )
end )
2024-08-26 19:58:11 -04:00
vim.keymap . set ( " n " , " <leader>lds " , telescope_builtins.lsp_document_symbols , { desc = " [D]ocument [S]ymbols " } )
vim.keymap . set ( " n " , " <leader>lws " , telescope_builtins.lsp_dynamic_workspace_symbols , { desc = " [W]orkspace [S]ymbols " } )
2024-01-05 16:34:03 -05:00
-- harpoon keymaps
vim.keymap . set ( " n " , " <Leader>ha " , function ( ) harpoon : list ( ) : append ( ) end )
vim.keymap . set ( " n " , " <Leader>he " , function ( ) harpoon.ui : toggle_quick_menu ( harpoon : list ( ) ) end )
vim.keymap . set ( " n " , " <Leader>hj " , function ( ) harpoon : list ( ) : prev ( ) end )
vim.keymap . set ( " n " , " <Leader>hk " , function ( ) harpoon : list ( ) : next ( ) end )
-- codelens keymaps
2023-08-23 19:04:11 -04:00
vim.keymap . set ( " n " , " <Leader>rr " , vim.lsp . codelens.run )
2023-08-04 15:41:25 -04:00
2024-01-05 16:34:03 -05:00
-- debugging DAP keymaps
2023-09-27 13:39:06 -04:00
vim.keymap . set ( " n " , " <Leader>tdb " , function ( )
2023-09-22 11:06:02 -04:00
vim.cmd ( " DBUIToggle " )
end )
2023-08-28 14:08:20 -04:00
2024-10-02 08:22:39 -05:00
require ( ' lualine ' ) . setup {
icons_enabled = false ,
disabled_filetypes = {
statusline = { } ,
winbar = { } ,
} ,
sections = {
-- left side
2025-05-08 19:50:57 -04:00
lualine_a = { ' mode ' } ,
lualine_b = { ' filename ' } ,
lualine_c = { ' encoding ' , ' fileformat ' , ' filetype ' } ,
2024-10-02 08:22:39 -05:00
-- right side
2025-05-08 19:50:57 -04:00
lualine_x = { ' diagnostics ' } ,
lualine_y = { ' progress ' , ' lsp_progress ' } ,
lualine_z = { ' location ' }
2024-10-02 08:22:39 -05:00
}
}
2024-10-11 16:09:08 -04:00
-- Hunk diff tree viewer and editor. Replacement for Meld and company
local hunk = require ( " hunk " )
hunk.setup ( {
2025-05-08 19:50:57 -04:00
keys = {
global = {
quit = { " q " } ,
accept = { " <leader><Cr> " } ,
focus_tree = { " <leader>e " } ,
} ,
2024-10-11 16:09:08 -04:00
2025-05-08 19:50:57 -04:00
tree = {
expand_node = { " l " , " <Right> " } ,
collapse_node = { " h " , " <Left> " } ,
2024-10-11 16:09:08 -04:00
2025-05-08 19:50:57 -04:00
open_file = { " <Cr> " } ,
2024-10-11 16:09:08 -04:00
2025-05-08 19:50:57 -04:00
toggle_file = { " a " } ,
} ,
diff = {
toggle_line = { " a " } ,
toggle_hunk = { " A " } ,
} ,
2024-10-11 16:09:08 -04:00
} ,
2025-05-08 19:50:57 -04:00
ui = {
tree = {
-- Mode can either be `nested` or `flat`
mode = " nested " ,
width = 35 ,
} ,
--- Can be either `vertical` or `horizontal`
layout = " vertical " ,
2024-10-11 16:09:08 -04:00
} ,
2025-05-08 19:50:57 -04:00
icons = {
selected = " " ,
deselected = " " ,
partially_selected = " " ,
folder_open = " " ,
folder_closed = " " ,
2024-10-11 16:09:08 -04:00
} ,
2025-05-08 19:50:57 -04:00
-- Called right after each window and buffer are created.
--hooks = {
-- ---@param _context { buf: number, tree: NuiTree, opts: table }
-- on_tree_mount = function(_context) end,
-- ---@param _context { buf: number, win: number }
-- on_diff_mount = function(_context) end,
--},
2024-10-11 16:09:08 -04:00
} )
2023-10-05 12:25:16 -04:00
local dap = require ( ' dap ' )
dap.adapters . lldb = {
type = " executable " ,
command = " /run/current-system/sw/bin/lldb " ,
name = " lldb " ,
}
dap.adapters . coreclr = {
2024-01-06 11:06:05 -05:00
type = ' executable ' ,
command = ' /run/current-system/sw/bin/netcoredbg ' ,
args = { ' --interpreter=vscode ' }
2023-10-05 12:25:16 -04:00
}
dap.configurations . rust = {
{
name = ' Launch Rust ' ,
type = ' lldb ' ,
request = ' launch ' ,
program = function ( )
2024-01-06 11:06:05 -05:00
return vim.fn . input ( ' Path to executable: ' , vim.fn . getcwd ( ) .. ' / ' , ' file ' )
2023-10-05 12:25:16 -04:00
end ,
cwd = ' ${workspaceFolder} ' ,
stopOnEntry = false ,
args = { } ,
} ,
}
dap.configurations . cs = {
{
name = " Launch - netcoredbg " ,
type = " coreclr " ,
request = " launch " ,
program = function ( )
return vim.fn . input ( ' Path to dll ' , vim.fn . getcwd ( ) , ' file ' )
end ,
} ,
}
2025-03-27 11:09:50 -04:00
2025-05-05 11:36:52 -04:00
local mcphub = require ( " mcphub " )
mcphub.setup ( {
-- This sets vim.g.mcphub_auto_approve to false by default (can also be toggled from the HUB UI with `ga`)
config = vim.fn . expand ( " ~/.config/mcphub/servers.json " ) ,
2025-05-08 19:50:57 -04:00
auto_approve = true ,
2025-05-05 11:36:52 -04:00
auto_toggle_mcp_servers = true , -- Let LLMs start and stop MCP servers automatically
extensions = {
avante = {
make_slash_commands = true , -- make /slash commands from MCP server prompts
2025-05-08 19:50:57 -04:00
} ,
2025-05-05 11:36:52 -04:00
} ,
2025-05-08 19:50:57 -04:00
cmd = " mcp-hub " ,
2025-05-05 11:36:52 -04:00
} )
2025-05-08 19:50:57 -04:00
function get_server_list_prompt ( hub_instance )
-- returns a list of mcp-servers with a `name` and a list of tools with `name`
local mcp_tool_prompt = " # MCP SERVERS \n \n The Model Context Protocol (MCP) enables communication between the system and locally running MCP servers that provide additional tools and resources to extend your capabilities. \n \n # Connected MCP Servers \n \n When a server is connected, you can use the server's tools via the `use_mcp_tool` tool, and access the server's resources via the `access_mcp_resource` tool. \n Note: Server names are case sensitive and you should always use the exact full name like `Firecrawl MCP` or `src/user/main/time-mcp` etc \n \n "
if not hub_instance then
return " "
end
local servers = hub_instance : get_servers ( )
if not servers or # servers == 0 then
return " "
end
for _ , server in ipairs ( servers ) do
mcp_tool_prompt = mcp_tool_prompt .. " ## server name: ` " .. server.name .. " ` \n \n "
if server.capabilities . tools and # server.capabilities . tools > 0 then
mcp_tool_prompt = mcp_tool_prompt .. " Available tools: \n \n "
for _ , tool in ipairs ( server.capabilities . tools ) do
mcp_tool_prompt = mcp_tool_prompt .. " - tool name: ` " .. tool.name .. " ` \n "
if tool.description then
mcp_tool_prompt = mcp_tool_prompt .. " - Description: " .. tool.description .. " \n "
end
end
mcp_tool_prompt = mcp_tool_prompt .. " \n "
end
end
return mcp_tool_prompt
end
function make_avante_system_prompt ( hub_instance )
return hub_instance and get_server_list_prompt ( hub_instance ) or " "
end
function update_avante_system_prompt ( )
local hub_instance = mcphub.get_hub_instance ( ) ;
local system_prompt = make_avante_system_prompt ( hub_instance )
if system_prompt then
require ( " avante.config " ) . override ( { system_prompt = system_prompt } )
end
end
2025-05-05 11:36:52 -04:00
2025-05-30 09:42:18 -04:00
vim.keymap . set ( " n " , " <Leader>ab " , function ( ) require ( ' avante ' ) . get ( ) . file_selector : add_buffer_files ( ) end )
vim.keymap . set ( " n " , " <Leader>af " , function ( ) require ( ' avante ' ) . get ( ) . file_selector : add_current_buffer ( ) end )
require ( ' copilot ' ) . setup ( )
2025-04-01 19:21:52 -04:00
2025-05-08 19:50:57 -04:00
require ( ' avante ' ) . setup ( {
2025-04-11 14:37:27 -04:00
provider = " claude " ,
2025-05-08 19:50:57 -04:00
mode = " planning " ,
cursor_applying_provider = nil , -- default to whatever provider is configured
2025-04-05 11:22:34 -04:00
claude = {
2025-05-08 19:50:57 -04:00
endpoint = " https://api.anthropic.com " ,
model = " claude-3-7-sonnet-20250219 " ,
timeout = 30000 , -- Timeout in milliseconds
temperature = 0 ,
max_tokens = 20480 ,
} ,
copilot = {
model = " claude-3.7-sonnet " ,
2025-05-02 12:06:52 -04:00
} ,
behavior = {
enable_cursor_planning_mode = true ,
2025-05-05 11:36:52 -04:00
} ,
2025-05-30 09:42:18 -04:00
windows = {
ask = {
start_insert = false ,
focus_on_apply = " theirs " ,
} ,
} ,
2025-05-08 19:50:57 -04:00
system_prompt = make_avante_system_prompt ( mcphub.get_hub_instance ( ) ) ,
2025-05-07 12:28:38 -04:00
custom_tools = { require ( " mcphub.extensions.avante " ) . mcp_tool ( ) } ,
2025-05-05 11:36:52 -04:00
-- Disable these because we'll use the mcphub versions instead
2025-05-08 19:50:57 -04:00
--disabled_tools = {
-- "list_files", -- Built-in file operations
-- "search_files",
-- "read_file",
-- "create_file",
-- "rename_file",
-- "delete_file",
-- "create_dir",
-- "rename_dir",
-- "delete_dir",
-- "bash", -- Built-in terminal access
--},
2025-03-27 11:09:50 -04:00
} )