| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935 |
- -- === === === === === === === === Neovim Config === === === === === === === ===
- --
- -- A configuration for Neovim that aims to be beautiful, intuitive, and
- -- pragmatic about plugin usage, while providing a developer experience on par
- -- with professional IDEs. It is tuned for usage with a custom keyboard
- -- layout and terminal configuration, and may not be as useful in other setups.
- --
- -- This configuration leverages a combination of keymaps and omnibars to give
- -- quick access to a large amount of functionality in an intuitive way. Most
- -- keymaps are unchanged from stock Neovim, with the notable exception of
- -- remapping most `s<a-Z>` keymaps.
- --
- -- === === === === === === === === === === === === === === === === === === ===
- --
- -- Core Options
- --
- -- === === === === === === === === === === === === === === === === === === ===
- -- Incantation to render correctly in Alacritty/tmux/macOS
- vim.cmd([[
- let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
- let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
- set termguicolors
- ]])
- -- File options
- vim.opt.wrap = false
- vim.opt.encoding = "UTF-8"
- vim.opt.hlsearch = true
- vim.opt.spell = true
- vim.opt.spelllang = "en_us"
- -- Display options
- vim.opt.pumheight = 15
- vim.opt.laststatus = 2
- vim.opt.showtabline = 2
- vim.opt.showcmd = true
- vim.opt.cmdheight = 0
- vim.opt.number = true
- vim.opt.relativenumber = true
- vim.opt.splitbelow = true
- vim.opt.splitright = true
- vim.opt.expandtab = true
- vim.opt.tabstop = 4
- vim.opt.shiftwidth = 4
- -- === === === === === === === === === === === === === === === === === === ===
- --
- -- Leader
- --
- -- === === === === === === === === === === === === === === === === === === ===
- vim.keymap.set({ 'n', 'v' }, 's', '<Nop>', { noremap = true, silent = true })
- vim.keymap.set({ 'n', 'v' }, 'S', '<Nop>', { noremap = true, silent = true })
- vim.g.mapleader = 's'
- vim.g.maplocalleader = vim.g.mapleader
- -- === === === === === === === === === === === === === === === === === === ===
- --
- -- Keymaps
- --
- -- === === === === === === === === === === === === === === === === === === ===
- -- Use `Alt-Arrow` to navigate between panes
- vim.keymap.set("i", "<A-left>", "<C-\\><C-N><C-w>W")
- vim.keymap.set("i", "<A-right>", "<C-\\><C-N><C-w>w")
- vim.keymap.set("i", "<S-A-left>", "<C-\\><C-N>:tabnext<CR>")
- vim.keymap.set("i", "<S-A-right>", "<C-\\><C-N>:tabprevious<CR>")
- vim.keymap.set("n", "<A-left>", "<C-w>W")
- vim.keymap.set("n", "<A-right>", "<C-w>w")
- vim.keymap.set("n", "<S-A-left>", ":tabnext<CR>")
- vim.keymap.set("n", "<S-A-right>", ":tabprevious<CR>")
- -- Folds toggled by homerow roll
- vim.keymap.set("n", "sr", ": normal za<CR>")
- -- Buffer actions
- vim.keymap.set("n", "SV", ":vsp<CR>")
- vim.keymap.set("n", "SQ", ":q<CR>")
- vim.keymap.set("n", "SH", ":noh<CR>")
- -- Yank to system clipboard
- vim.keymap.set({ "n", 'v' }, "Y", "\"+y")
- -- Yank file properties to system clipboard
- local yank_filename = function(full, line)
- local filename = vim.fn.expand("%")
- if full then filename = vim.fn.expand("%:p") end
- if line then filename = filename .. ":" .. vim.api.nvim_win_get_cursor(0)[1] end
- vim.fn.setreg("+", filename)
- end
- vim.keymap.set("n", "Syan", function() yank_filename(true, false) end)
- vim.keymap.set("n", "Syal", function() yank_filename(true, true) end)
- vim.keymap.set("n", "Syrn", function() yank_filename(false, false) end)
- vim.keymap.set("n", "Syrl", function() yank_filename(false, true) end)
- vim.keymap.set("n", "Syf", function() yank_filename(false, false) end)
- -- === === === === === === === === === === === === === === === === === === ===
- --
- -- Language Servers
- --
- -- === === === === === === === === === === === === === === === === === === ===
- -- See configurations in `lsp/*.lua`
- vim.lsp.config("*", {
- cmd_cwd = vim.fn.expand("~"),
- root_markers = { ".git" },
- })
- -- Enable all language servers with extant configurations
- for _, filename in pairs(vim.split(io.popen("ls -a " .. vim.fn.stdpath("config")
- .. "/lsp"):read("*a"), "\n")) do
- if filename:match(".lua$") ~= nil then
- vim.lsp.enable(filename:sub(1, -5))
- end
- end
- -- LSP Keymaps
- vim.api.nvim_create_autocmd("LspAttach", {
- callback = function(_)
- vim.keymap.set("n", "SR", vim.lsp.buf.rename)
- vim.keymap.set("n", "Sx", vim.lsp.buf.code_action)
- vim.keymap.set("n", "<Space>", vim.lsp.buf.hover)
- vim.keymap.set("n", "SI", function()
- local diagnostic_config = vim.diagnostic.config()
- if (vim.lsp.inlay_hint.is_enabled()) then
- vim.lsp.inlay_hint.enable(false)
- vim.diagnostic.config({
- virtual_lines = {
- current_line = true,
- ---@diagnostic disable-next-line: need-check-nil, undefined-field
- format = diagnostic_config.format
- }
- })
- else
- vim.lsp.inlay_hint.enable(true)
- vim.diagnostic.config({
- virtual_lines = true,
- ---@diagnostic disable-next-line: need-check-nil, undefined-field
- format = diagnostic_config.format
- })
- end
- end)
- end
- })
- -- === === === === === === === === === === === === === === === === === === ===
- --
- -- Plugins Declarations
- --
- -- === === === === === === === === === === === === === === === === === === ===
- vim.pack.add({
- "https://github.com/hrsh7th/cmp-buffer",
- "https://github.com/hrsh7th/cmp-calc",
- "https://github.com/hrsh7th/cmp-cmdline",
- "https://github.com/hrsh7th/cmp-nvim-lsp",
- "https://github.com/hrsh7th/cmp-nvim-lsp-signature-help",
- "https://github.com/hrsh7th/cmp-nvim-lua",
- "https://github.com/hrsh7th/cmp-path",
- "https://github.com/hrsh7th/nvim-cmp",
- "https://github.com/kylechui/nvim-surround",
- "https://github.com/lewis6991/gitsigns.nvim",
- "https://github.com/lukas-reineke/virt-column.nvim",
- "https://github.com/nvim-lua/plenary.nvim",
- "https://github.com/nvim-telescope/telescope-file-browser.nvim",
- "https://github.com/nvim-telescope/telescope-ui-select.nvim",
- "https://github.com/nvim-telescope/telescope.nvim",
- "https://github.com/nvim-treesitter/nvim-treesitter",
- "https://github.com/nvim-treesitter/nvim-treesitter-context",
- "https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
- "https://github.com/psliwka/vim-dirtytalk",
- "https://github.com/stevearc/aerial.nvim",
- "https://github.com/tpope/vim-commentary"
- })
- for _, plugin in ipairs({
- "like-a-butterfly",
- "bit-browser",
- "command-palette",
- "jonathandarker",
- "jxdash",
- "like-a-butterfly",
- "maj-peg",
- "pandoctrinated",
- "proj-conf",
- "save-formatter",
- "status-beast",
- "telescope-shroud",
- }) do
- vim.opt.runtimepath:prepend(vim.fn.stdpath("config") ..
- "/custom/" .. plugin)
- end
- -- === === === === === === === === === === === === === === === === === === ===
- --
- -- Plugins Configurations
- --
- -- === === === === === === === === === === === === === === === === === === ===
- local function config_command_palette()
- local palette = require("command-palette")
- palette.add({
- {
- "Manage project", "", {
- {
- "Close project",
- "Safely close the project and then close the associated tmux pane",
- function()
- vim.api.nvim_create_autocmd({ "VimLeave" }, {
- pattern = { "*" },
- group = vim.api.nvim_create_augroup(
- "tmux_close_group", { clear = true }),
- callback = function()
- vim.api.nvim_exec("!tmux kill-pane",
- false)
- end
- })
- vim.api.nvim_exec("qa", true)
- end
- }
- }
- }, {
- "Manage Neovim", "", {
- {
- "Update plugins",
- "",
- function() vim.pack.update() end
- }
- }
- }
- })
- vim.keymap.set("n", "<Leader>P", palette.open)
- vim.keymap.set("n", "<Leader>p", palette.open_full)
- vim.keymap.set("n", "<Leader>L", function()
- palette.open({}, "LSP Finders", {
- { "Treesitter", "", ":Telescope treesitter" },
- { "LSP References", "", ":Telescope lsp_references" },
- { "LSP Incoming Calls", "", ":Telescope lsp_incoming_calls" },
- { "LSP Outgoing Calls", "", ":Telescope lsp_outgoing_calls" },
- {
- "LSP Document Symbols", "",
- ":Telescope lsp_document_symbols"
- },
- {
- "LSP Workspace Symbols", "",
- ":Telescope lsp_workspace_symbols"
- }, {
- "LSP Dynamic Workspace Symbols", "",
- ":Telescope lsp_workspace_symbols"
- }, { "Diagnostics", "", ":Telescope diagnostics" },
- {
- "LSP Implementations", "",
- ":Telescope lsp_implementations"
- }, { "LSP Definitions", "", ":Telescope lsp_definitions" },
- {
- "LSP Type Definitions", "",
- ":Telescope lsp_type_definitions"
- }
- })
- end)
- end
- local function config_bit_browser()
- local bitbrowser = require("bit-browser")
- vim.keymap.set("n", "n", bitbrowser.next)
- vim.keymap.set("n", "N", bitbrowser.prev)
- for i, v in pairs({ 'e', 'w', 'i', 'd', 's', 'g' }) do
- vim.keymap.set("n", "<Leader>n" .. v, function()
- bitbrowser.set_target(i);
- bitbrowser.next()
- end)
- vim.keymap.set("n", "<Leader>N" .. v, function()
- bitbrowser.set_target(i);
- bitbrowser.prev()
- end)
- end
- end
- local function config_save_formatter()
- local formatter = require("save-formatter")
- formatter.setup()
- vim.keymap.set("n", "Sw",
- function() vim.api.nvim_exec2("write", {}) end)
- require("command-palette").add({ {
- "Save Formatter", "Configure automatic formatters", formatter.picker }
- })
- end
- local function config_pandoctrinated()
- local pandoctrinated = require("pandoctrinated")
- vim.keymap.set("n", "Sfd", pandoctrinated.pandoc_format_docstring)
- require("command-palette").add({ {
- "Pandoctrinated", "Format \"\"\"docstring\"\"\" with `pandoc`",
- pandoctrinated.pandoc_format_docstring }
- })
- end
- local function config_nvim_cmp()
- local cmp = require("cmp")
- local mapping = {
- ["<Tab>"] = function(fallback)
- if cmp.visible() then
- cmp.select_next_item(
- { behavior = cmp.SelectBehavior.Select })
- else
- fallback()
- end
- end,
- ["<S-Tab>"] = function(fallback)
- if cmp.visible() then
- cmp.select_prev_item(
- { behavior = cmp.SelectBehavior.Select })
- else
- fallback()
- end
- end,
- ["<CR>"] = function(fallback)
- if cmp.visible() and cmp.get_active_entry() then
- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace })
- else
- fallback()
- end
- end
- }
- cmp.setup({
- snippet = {},
- mapping = mapping,
- sources = cmp.config.sources({ { name = "nvim_lsp" } }, {
- { name = "buffer" }, { name = "nvim_lua" }, { name = "calc" },
- { name = "nvim_lsp_signature_help" }, { name = "path" }
- })
- })
- cmp.setup.cmdline("/", {
- mapping = cmp.mapping.preset.cmdline(),
- sources = { { name = "buffer" } }
- })
- cmp.setup.cmdline(":", {
- mapping = cmp.mapping.preset.cmdline(),
- sources = cmp.config.sources({ { name = "path" } }, {
- { name = "cmdline", option = { ignore_cmds = { "Man", "!" } } }
- })
- })
- vim.api.nvim_create_autocmd("LspAttach", {
- callback = function(args)
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- if client == nil then return end
- if client:supports_method('textDocument/completion') then
- vim.lsp.completion.enable(true, client.id, args.buf,
- { autotrigger = false })
- end
- end
- })
- end
- local function config_maj_peg()
- local mp = require("maj-peg")
- mp.setup()
- require("command-palette").add({
- {
- "maj-peg", "Diagnostic integration for `mypy`", {
- {
- "Toggle maj-peg",
- function()
- if mp.status().enabled then
- return "Disable `mypy` integration"
- else
- return "Enable `mypy` integration"
- end
- end,
- mp.toggle } }
- }
- })
- end
- local function config_like_a_butterfly()
- local lab = require('like-a-butterfly')
- local augroup = vim.api.nvim_create_augroup(
- 'like-a-butterfly', { clear = true })
- function MakeTerm(shortcut, name, command, flaky)
- lab.create_term(name, command)
- vim.keymap.set("n", "<Leader>" .. shortcut, function()
- if flaky then
- local flaky_redraw_time = 10
- vim.api.nvim_create_autocmd({ "BufEnter" },
- {
- pattern = { "*" },
- group = augroup,
- once = true,
- callback = function()
- if (vim.bo.filetype ~= "butterfly") then
- return
- end
- local window = vim.api
- .nvim_get_current_win()
- vim.cmd(
- "setlocal sidescrolloff=" ..
- vim.o
- .columns)
- vim.defer_fn(function()
- vim.api.nvim_win_set_height(
- window,
- vim.api
- .nvim_win_get_height(
- window) -
- 1)
- vim.defer_fn(function()
- vim.api
- .nvim_win_set_height(
- window,
- vim.api
- .nvim_win_get_height(
- window) + 1)
- vim.api.nvim_feedkeys(
- vim.api
- .nvim_replace_termcodes(
- '<C-\\><C-n>^zei',
- true, true, true),
- 'i', true)
- vim.schedule(function()
- vim.cmd("redraw!")
- end)
- end, flaky_redraw_time)
- end, flaky_redraw_time)
- vim.cmd("redraw!")
- end
- })
- end
- lab.open_term(name)
- end)
- end
- vim.api.nvim_create_autocmd({ "BufEnter" },
- {
- pattern = { "*" },
- group = augroup,
- callback = function()
- vim
- .schedule(function()
- if (vim.bo.filetype ~= "butterfly") then
- lab.close_all()
- end
- end)
- end
- })
- MakeTerm("tt", "Alpha", "zsh")
- MakeTerm("ts", "Beta", "zsh")
- MakeTerm("tr", "Gamma", "zsh")
- MakeTerm("ta", "Delta", "zsh")
- MakeTerm("tn", "Epsilon", "gemini --model gemini-2.5-pro")
- MakeTerm("te", "Zeta", "/bin/zsh $DOTFILES_DIR/.scripts/omniscratch.zsh")
- MakeTerm("ti", "Eta", "lazydocker", true)
- MakeTerm("to", "Theta", "lazygit", true)
- vim.keymap.set("t", "<C-S-t>", "<C-\\><C-n>")
- vim.keymap.set("t", "<S-Space>", "<Esc>")
- local timer_var = "lab_doubletap_timer"
- vim.keymap.set("t", "<Esc>", function()
- if vim.b[timer_var] then
- vim.fn.timer_stop(vim.b[timer_var])
- vim.b[timer_var] = nil
- lab.close_all()
- else
- vim.b[timer_var] = vim.fn.timer_start(150, function()
- vim.b[timer_var] = nil
- vim.api.nvim_chan_send(
- vim.b.terminal_job_id,
- vim.api.nvim_replace_termcodes("<Esc>", true, false, true))
- end)
- end
- end, { noremap = true, silent = true })
- end
- local function config_gitsigns()
- local gitsigns = require("gitsigns")
- gitsigns.setup {
- diff_opts = {
- internal = true,
- linematch = 1,
- algorithm = "minimal"
- },
- signcolumn = true,
- numhl = false,
- linehl = false,
- max_file_length = 50000,
- word_diff = false,
- auto_attach = true,
- attach_to_untracked = true
- }
- local pickers = require("telescope.pickers")
- local actions = require("telescope.actions")
- local action_state = require("telescope.actions.state")
- local finders = require("telescope.finders")
- local conf = require("telescope.config").values
- local entry_display = require("telescope.pickers.entry_display")
- local palette = require("command-palette")
- local open_picker = function(title, command)
- local displayer = entry_display.create({
- separator = " ▏",
- items = {
- { width = 16 }, { width = 64 }, { width = 24 },
- { remaining = true }
- }
- })
- local results = vim.split(vim.fn.system(
- "git log --branches=\\* --pretty='format:%H ||!|| %cr ||!|| %(decorate:prefix=,suffix=,separator= ) ||!|| %an ||!|| %s' --since='last month'"),
- "\n")
- pickers.new({}, {
- prompt_title = title,
- finder = finders.new_table({
- results = results,
- entry_maker = function(entry)
- local s = vim.split(entry, "||!||")
- return {
- value = s[1],
- display = function()
- return displayer({
- { s[2] }, { s[3] }, { s[4] }, { s[5] }
- })
- end,
- ordinal = string.format("%s %s", s[3], s[5])
- }
- end
- }),
- sorter = conf.generic_sorter(),
- attach_mappings = function(prompt_bufnr, _)
- actions.select_default:replace(function()
- actions.close(prompt_bufnr)
- local hash = action_state.get_selected_entry().value
- if command == "base" then
- vim.api.nvim_exec(
- ":Gitsigns change_base " .. hash .. " true",
- true)
- elseif command == "diff" then
- vim.api.nvim_exec(":Gitsigns diffthis " .. hash,
- true)
- end
- end)
- return true
- end
- }):find()
- end
- local open_diff_picker =
- function()
- open_picker("Gitsigns Diff", "diff")
- end
- local open_base_picker = function()
- open_picker("Gitsigns Change Base", "base")
- end
- vim.keymap.set("n", "Sgd", open_diff_picker)
- vim.keymap.set("n", "Sgb", open_base_picker)
- palette.add({
- {
- "Gitsigns", "", {
- {
- "Diff file",
- "Open the Gitsigns differ for this file",
- open_diff_picker
- },
- {
- "Change diff base",
- "Change base branch for Gitsigns to diff again",
- open_base_picker
- }
- }
- }
- })
- end
- local function config_proj_conf()
- require("proj-conf").setup()
- end
- local function config_vim_dirtytalk()
- vim.opt.spelllang = { "en_us", "programming" }
- end
- local function config_jonathandarker()
- vim.cmd.colorscheme("jonathandarker")
- vim.opt.list = true
- vim.opt.fillchars = "horiz:-," .. "horizup:-," .. "horizdown:-," ..
- "vert:¦," .. "verthoriz:¦," ..
- "vertleft:¦," .. "vertright:¦," ..
- "eob:⠀"
- vim.opt.listchars = "extends:›," .. "precedes:‹," ..
- "tab:\\ ," .. "nbsp:·," .. "trail:·," ..
- "space:·"
- end
- local function config_status_beast()
- require("status-beast.highlights").setup()
- require("status-beast").setup()
- vim.api.nvim_create_autocmd({ "BufEnter" },
- {
- group = vim.api.nvim_create_augroup('StatusBeast',
- { clear = true }),
- callback = function (args)
- if vim.bo[args.buf].filetype == "aerial" then
- return
- end
- require("status-beast").setup()
- end
- })
- vim.diagnostic.config({
- virtual_lines = {
- current_line = true,
- format = function(d)
- return "[" .. d.source .. "] " .. d.message
- end
- },
- float = false,
- virtual_text = false,
- update_in_insert = true
- })
- local palette = require("command-palette")
- palette.add({
- {
- "Status Beast", "Options for status bars and columns", { {
- "Toggle Relnum", "Toggle relative line numbers on/off",
- ":setl rnu!" } } }
- })
- end
- local function config_jxdash()
- require("jxdash").setup()
- end
- local function config_virt_column()
- vim.opt.colorcolumn = tostring(80 + 1)
- local cc_group = vim.api.nvim_create_augroup("colorcolumn",
- { clear = true })
- local filetype_colorcolumn_map = {
- python = 88,
- kotlin = 100,
- julia = 92
- }
- vim.api.nvim_create_autocmd({ "FileType" }, {
- pattern = { "*" },
- group = cc_group,
- callback = function(event)
- local filetype = vim.bo[event.buf].filetype
- local colorcolumn = filetype_colorcolumn_map[filetype]
- if colorcolumn == nil then
- colorcolumn = 80
- end
- for _, w in pairs(vim.api.nvim_list_wins()) do
- if vim.api.nvim_win_get_buf(w) == event.buf then
- vim.wo[w].colorcolumn = tostring(colorcolumn + 1)
- end
- end
- end
- })
- require("virt-column").setup({ char = "⁚" })
- end
- local function config_telescope()
- local builtin = require("telescope.builtin")
- require("telescope").setup({
- extensions = {
- ["ui-select"] = { require("telescope.themes").get_dropdown() }
- },
- defaults = {
- ["borderchars"] = {
- "-", "¦", "-", "¦", "⌌", "⌍", "⌏", "⌎"
- },
- layout_strategy = "horizontal",
- layout_config = {
- horizontal = { width = { padding = 0 }, height = 0.99 }
- },
- cache_picker = {
- num_pickers = 100,
- limit_entries = 100,
- ignore_empty_prompt = true
- }
- },
- pickers = {
- live_grep = {
- additional_args = function(_)
- return { "--hidden", "--glob=!**/.git/*" }
- end
- }
- }
- })
- vim.keymap.set("n", "<Leader>f", function()
- require("telescope").extensions.file_browser.file_browser({
- select_buffer = true,
- grouped = true,
- no_ignore = true,
- hidden = true,
- respect_gitignore = false,
- path = vim.fn.expand("%:p:h")
- })
- end, {})
- vim.keymap.set("n", "<Leader>s", builtin.resume)
- vim.keymap.set("n", "<Leader>S", builtin.pickers)
- vim.keymap.set("n", "<Leader>T", builtin.treesitter)
- vim.keymap.set("n", "<Leader>a", builtin.find_files)
- vim.keymap.set("n", "<Leader>g", builtin.git_files)
- vim.keymap.set("n", "<Leader>G", builtin.git_status)
- vim.keymap.set("n", "<Leader>b", builtin.buffers)
- vim.keymap.set("n", "<Leader>j", builtin.jumplist)
- vim.keymap.set("n", "<Leader>w", builtin.grep_string)
- vim.keymap.set("n", "<Leader>ld", builtin.lsp_definitions)
- vim.keymap.set("n", "<Leader>lt", builtin.lsp_type_definitions)
- vim.keymap.set("n", "<Leader>lr", builtin.lsp_references)
- vim.keymap.set("n", "<Leader>li", builtin.lsp_implementations)
- vim.keymap.set("n", "<Leader>ls", builtin.lsp_document_symbols)
- vim.keymap.set("n", "<Leader>lS", builtin.lsp_workspace_symbols)
- require("telescope").load_extension("ui-select")
- require("telescope").load_extension("file_browser")
- end
- local function config_telescope_file_browser()
- require("telescope").setup({
- extensions = {
- file_browser = {
- respect_gitignore = false,
- hidden = { file_browser = true, folder_browser = true },
- hijack_netrw = true,
- display_stat = { date = false, size = true, mode = false },
- mappings = {}
- }
- }
- })
- require("telescope").load_extension("file_browser")
- end
- local function config_telescope_shroud()
- local shroud = require("telescope-shroud")
- local palette = require("command-palette")
- palette.add({
- {
- "Telescope Shroud", "Telescope `grep` filter management", { {
- "Populate", "Reload the list of filter options", shroud.populate
- }, {
- "Clear default", "Reset the default filters", function()
- shroud.set_default({})
- end
- }, {
- "Set default", "Set the default filters", shroud.set_default }, {
- "Open default", "Set the default filters", shroud.open_default }, {
- "Open narrow", "Set the default filters", shroud.open_narrow } } }
- })
- vim.keymap.set("n", "<Leader>i", shroud.open_default)
- vim.keymap.set("n", "<Leader>I", shroud.open_narrow)
- end
- local function config_nvim_surround()
- require("nvim-surround").setup({})
- end
- local function config_nvim_treesitter_textobjects()
- require("nvim-treesitter.configs").setup({
- textobjects = {
- select = {
- enable = true,
- lookahead = true,
- keymaps = {
- ["af"] = "@function.outer",
- ["if"] = "@function.inner",
- ["ac"] = "@class.outer",
- ["ic"] = "@class.inner",
- ["ap"] = "@parameter.outer",
- ["ip"] = "@parameter.inner",
- ["aa"] = "@parameter.outer",
- ["ia"] = "@parameter.inner",
- ["al"] = "@loop.outer",
- ["il"] = "@loop.inner",
- ["at"] = "@attribute.outer",
- ["it"] = "@attribute.inner",
- ["a="] = "@assignment.outer",
- ["i="] = "@assignment.inner",
- ["ab"] = "@block.outer",
- ["ib"] = "@block.inner"
- },
- include_surrounding_whitespace = true
- },
- swap = {
- enable = true,
- swap_next = {
- ["csf"] = "@function.inner",
- ["csc"] = "@class.inner",
- ["csp"] = "@parameter.inner",
- ["csa"] = "@parameter.inner",
- ["csl"] = "@loop.inner",
- ["cst"] = "@attribute.inner",
- ["cs="] = "@assignment.inner",
- ["csb"] = "@block.inner"
- },
- swap_previous = {
- ["cSf"] = "@function.inner",
- ["cSc"] = "@class.inner",
- ["cSp"] = "@parameter.inner",
- ["cSa"] = "@parameter.inner",
- ["cSl"] = "@loop.inner",
- ["cSt"] = "@attribute.inner",
- ["cS="] = "@assignment.inner",
- ["cSb"] = "@block.inner"
- }
- }
- }
- })
- end
- local function config_nvim_treesitter()
- local api = require("nvim-treesitter.configs")
- api.setup({
- ensure_installed = "all",
- sync_install = false,
- auto_install = true,
- ignore_install = { "ipkg" },
- highlight = {
- enable = true,
- additional_vim_regex_highlighting = false
- }
- })
- vim.opt.foldmethod = "expr"
- vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
- vim.api.nvim_create_autocmd("LspAttach", {
- callback = function(args)
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- if vim.treesitter ~= nil and client ~= nil and
- type(vim.treesitter.highlighter.active[args.buf]) ~= "nil" then
- client.server_capabilities.semanticTokensProvider = nil
- end
- end
- })
- end
- local function config_nvim_treesitter_context()
- require("treesitter-context").setup({
- enable = true,
- max_lines = 5,
- min_window_height = 0,
- line_numbers = true,
- multiline_threshold = 20,
- trim_scope = "outer",
- mode = "cursor",
- zindex = 20,
- on_attach = nil
- })
- vim.api.nvim_set_hl(0, "TreesitterContextSeparator",
- { link = "WinSeparator" })
- vim.keymap.set("n", "<Leader>c", function()
- require("treesitter-context").go_to_context(vim.v.count1)
- end, { silent = true })
- end
- local function config_aerial()
- require("aerial").setup({
- backends = { "treesitter", "lsp" },
- attach_mode = "global",
- highlight_closest = true,
- autojump = true,
- layout = {
- default_direction = "left",
- width = 40,
- placement = "window",
- winopts = {
- statuscolumn = ""
- }
- },
- nerd_font = "auto",
- icons = {
- Array = "[a]",
- Boolean = "[b]",
- Class = "[C]",
- Constant = "[const]",
- Constructor = "[Co]",
- Enum = "[E]",
- EnumMember = "[em]",
- Event = "[Ev]",
- Field = "[Fld]",
- File = "[File]",
- Function = "[F]",
- Interface = "[I]",
- Key = "[K]",
- Method = "[M]",
- Module = "[Mod]",
- Namespace = "[NS]",
- Null = "[-]",
- Number = "[n]",
- Object = "[o]",
- Operator = "[+]",
- Package = "[Pkg]",
- Property = "[P]",
- String = "[str]",
- Struct = "[S]",
- TypeParameter = "[T]",
- Variable = "[V]",
- Collapsed = "▶",
- },
- on_attach = function(bufnr)
- vim.keymap.set("n", "[[", "<cmd>AerialPrev<CR>", { buffer = bufnr })
- vim.keymap.set("n", "]]", "<cmd>AerialNext<CR>", { buffer = bufnr })
- end,
- })
- vim.keymap.set("n", "Sa", ":AerialOpen<CR>")
- vim.keymap.set("n", "SA", ":AerialToggle!<CR>")
- vim.api.nvim_create_autocmd({ "FileType", "BufEnter" }, {
- group = vim.api.nvim_create_augroup("AerialConfig", { clear = true }),
- callback = function(args)
- for _, win in ipairs(vim.fn.getwininfo()) do
- if (win.bufnr == args.buf) then
- vim.wo[win.winid].statuscolumn = ""
- end
- end
- end,
- })
- end
- local setup_plugins = function()
- config_jonathandarker()
- config_nvim_treesitter()
- config_vim_dirtytalk()
- config_virt_column()
- config_nvim_surround()
- config_like_a_butterfly()
- config_nvim_cmp()
- config_telescope()
- config_jxdash()
- config_nvim_treesitter_textobjects()
- config_nvim_treesitter_context()
- config_aerial()
- config_telescope_file_browser()
- config_command_palette()
- config_maj_peg()
- config_bit_browser()
- config_save_formatter()
- config_pandoctrinated()
- config_gitsigns()
- config_telescope_shroud()
- config_proj_conf()
- config_status_beast()
- end
- setup_plugins()
|