This commit is contained in:
Vladan Popovic 2024-09-30 00:38:42 +02:00
parent 4e28ba124e
commit f28a48967f
17 changed files with 1713 additions and 0 deletions

View file

@ -0,0 +1,250 @@
require("catppuccin").setup({
-- transparent_background = vim
flavour = "latte",
highlight_overrides = {
all = function(colors)
return {
FloatBorder = { link = "SagaBorder", fg="#4f4f4f" },
LineNr = { fg = colors.subtext0 },
Folded = { fg = colors.green },
MatchWord = { bold = true },
Visual = { sp = colors.text, underline = true },
IndentBlankLineContextChar = { fg = colors.sapphire },
WinSeparator = { fg = colors.text },
TelescopeSelection = { fg = colors.subtext1, bg = colors.surface0 },
TelescopeBorder = { fg = colors.surface1, bg = colors.surface1 },
TelescopeNormal = { bg = "#fafafa" },
TelescopePromptNormal = { bg = colors.surface1 },
TelescopePromptBorder = { bg = colors.surface1, fg = colors.surface1 },
CursorLine = { bg = colors.text },
NvimTreeWinSeparator = { fg = colors.text },
NvimTreeGitNew = { fg = colors.green },
NvimTreeGitDirty = { fg = colors.yellow },
NvimTreeGitDeleted = { fg = colors.red },
-- ColorColumn = { bg = colors. },
SpecialKey = { fg = colors.yellow },
SagaBorder = { fg = colors.blue },
HoverNormal = { fg = colors.text },
-- Gitsigns
GitSignsAddInline = { link = "DiffAdd" },
GitSignsDeleteInline = { link = "DiffDelete" },
GitSignsChangedInline = { link = "DiffChange" } ,
Diffview = { link = "DiffChange" } ,
StNormalMode = { fg = colors.surface0, bg = colors.blue, bold = true },
StVisualMode = { fg = colors.surface0, bg = colors.sky, bold = true },
StInsertMode = { fg = colors.surface0, bg = colors.lavender, bold = true },
StTerminalMode = { fg = colors.surface0, bg = colors.green, bold = true },
StNTerminalMode = { fg = colors.surface0, bg = colors.yellow, bold = true },
StReplaceMode = { fg = colors.surface0, bg = colors.peach, bold = true },
StConfirmMode = { fg = colors.surface0, bg = colors.sapphire, bold = true },
StCommandMode = { fg = colors.surface0, bg = colors.green, bold = true },
StSelectMode = { fg = colors.surface0, bg = colors.blue, bold = true },
StInviSep = { bg = colors.surface1, fg = colors.surface1 },
StNormalModeSep = { bg = colors.surface1, fg = colors.blue },
StVisualModeSep = { bg = colors.surface1, fg = colors.sky },
StInsertModeSep = { bg = colors.surface1, fg = colors.lavender },
StTerminalModeSep = { bg = colors.surface1, fg = colors.green },
StNTerminalModeSep = { bg = colors.surface1, fg = colors.yellow },
StReplaceModeSep = { bg = colors.surface1, fg = colors.peach },
StConfirmModeSep = { bg = colors.surface1, fg = colors.sapphire },
StCommandModeSep = { bg = colors.surface1, fg = colors.green },
StSelectModeSep = { bg = colors.surface1, fg = colors.blue },
--CurFile
StCwd = { bg = colors.yellow, fg = colors.text },
StFile = { bg = colors.peach, fg = colors.text, bold = true },
StCwdSep = { fg = colors.yellow, bg = colors.surface1 },
StFileSep = { fg = colors.peach, bg = colors.surface1 },
StDirFileSep = { fg = colors.yellow, bg = colors.peach },
-- Git stuffs
StGitBranch = { bg = colors.overlay0, fg = colors.mauve },
StGitAdded = { bg = colors.overlay0, fg = colors.green },
StGitChanged = { bg = colors.overlay0, fg = colors.yellow },
StGitRemoved = { bg = colors.overlay0, fg = colors.red },
StGitSep = { bg = colors.surface1, fg = colors.overlay0 },
-- LSP
StLSPClient = { bg = colors.surface1, fg = colors.blue, bold = true },
StLSPDiagSep = { bg = colors.surface1, fg = colors.overlay0 },
StLSPErrors = { bg = colors.overlay0, fg = colors.red },
StLSPWarnings = { bg = colors.overlay0, fg = colors.yellow },
StLSPHints = { bg = colors.overlay0, fg = colors.mauve },
StLspInfo = { bg = colors.overlay0, fg = colors.sky },
--
-- Lsp Diagnostics
DiagnosticHint = { fg = colors.mauve },
DiagnosticError = { fg = colors.red },
DiagnosticWarn = { fg = colors.yellow },
DiagnosticInformation = { fg = colors.green },
-- File Info
StPosition = { bg = colors.sapphire, fg = colors.surface1 },
StPositionSep = { bg = colors.surface1, fg = colors.sapphire },
TabLineFill = { fg = colors.text, bg = colors.crust, sp = colors.text },
TabLineBufHidden = { fg = colors.mantle, bg = colors.subtext1, sp = colors.text },
TabLineBufActive = { fg = colors.text, bg = colors.sapphire, bold = true, sp = colors.text },
TabLineCurrentBuf = { fg = colors.mantle, bg = colors.red, bold = true, sp = colors.text },
TabLineBufHiddenModified = { fg = colors.green, bg = colors.subtext1, sp = colors.text },
TabLineBufActiveModified = { fg = colors.green, bg = colors.sapphire, bold = true, sp = colors.text },
TabLineCurrentBufModified = { fg = colors.green, bg = colors.red, bold = true, sp = colors.text },
TabLineModified = { fg = colors.green },
TabLineCurrentTab = { fg = colors.mantle, bg = colors.red, bold = true, sp = colors.text },
TabLineOtherTab = { fg = colors.mantle, bg = colors.subtext1, sp = colors.text },
TabLineBufActiveSep = { fg = colors.sapphire, bg = colors.crust, sp = colors.text },
TabLineCurrentBufSep = { fg = colors.red, bg = colors.crust, sp = colors.text },
TabLineBufHiddenSep = { fg = colors.subtext1, bg = colors.crust, sp = colors.text },
DiagnosticUnnecessary = { link = "" },
--["@conceal.checked"] = { fg = colors.teal },
--["@none"] = { link = "Normal" },
--["@field"] = { fg = colors.blue },
--["@comment.todo"] = { fg = colors.lavender },
--["@property"] = { fg = colors.blue },
--["@variable.member"] = { fg = colors.blue },
--["@variable.parameter"] = { fg = colors.sky },
--["@parameter"] = { fg = colors.sky },
--["@comment.note"] = { link = "@comment.hint" },
--["@lsp.type.annotation"] = { fg = colors.darkyellow },
--["@lsp.type.modifier.java"] = { link = "@type.qualifier" },
--["@lsp.mod.builtin"] = { fg = colors.maroon },
--["@lsp.mod.readonly.python"] = { link = "Constant" },
--["@lsp.mod.documentation"] = { bold = true, fg = colors.mauve },
--["@lsp.type.keyword"] = { fg = colors.mauve },
}
end,
latte = function(colors)
return {
-- ["@lsp.type.keyword"] = { fg = colors.darkyellow },
Comment = { fg = colors.blue },
Conditional = { fg = colors.darkyellow },
Error = { fg = colors.base, bg = colors.red },
Exception = { fg = colors.peach },
Function = { fg = colors.cyan },
Identifier = { fg = colors.green },
Include = { fg = colors.pink },
Keyword = { fg = colors.darkyellow },
Operator = { fg = colors.darkyellow },
Parameter = { fg = colors.sky },
Special = { fg = colors.flamingo },
Statement = { fg = colors.darkyellow },
String = { fg = colors.red },
Structure = { fg = colors.green },
WhitespaceError = { fg = colors.base, bg = colors.red },
Type = { fg = colors.cyan },
StorageClass = { fg = colors.green },
--Macro = { fg = colors.magenta },
--Define = { fg = colors.magenta },
}
end,
},
color_overrides = {
latte = {
base = "#ffffff",
flamingo = "#bb5d60",
pink = "#d54597",
mauve = "#a65fd5",
red = "#D90E18",
maroon = "#db3e68",
peach = "#e46f2a",
yellow = "#bc8705",
darkyellow = "#B2640B",
green = "#1a8e32",
teal = "#00a390",
sky = "#089ec0",
sapphire = "#0ea0a0",
blue = "#017bca",
lavender = "#8584f7",
text = "#222222",
subtext1 = "#444444",
subtext0 = "#666666",
overlay2 = "#777777",
overlay1 = "#888888",
overlay0 = "#999999",
surface2 = "#aaaaaa",
surface1 = "#cccccc",
surface0 = "#e5e5e5",
mantle = "#eeeeee",
crust = "#dddddd",
cyan = "#0EB1A2",
magenta = "#FF00FF",
},
},
background = {
light = "latte",
dark = "mocha",
},
term_colors = true,
-- dim_inactive = {
-- enabled = true,
-- shade = "light",
-- percentage = 0.20,
-- },
styles = {
comments = {},
},
integrations = {
alpha = false,
cmp = true,
dap = true,
dap_ui = true,
dashboard = false,
flash = false,
gitsigns = true,
leap = true,
mini = {
enabled = false,
},
mason = true,
markdown = true,
neogit = true,
nvimtree = true,
ufo = false,
rainbow_delimiters = false,
semantic_tokens = true,
telescope = { enabled = true, style = "nvchad" },
treesitter = false,
barbecue = false,
illuminate = false,
indent_blankline = {
enabled = true,
colored_indent_levels = false,
},
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
},
underlines = {
errors = { "underline" },
hints = { "underline" },
warnings = { "underline" },
information = { "underline" },
},
inlay_hints = {
background = true,
},
},
lsp_saga = true,
lsp_trouble = true,
navic = {
enabled = false,
custom_bg = "NONE",
},
dropbar = {
enabled = false,
color_mode = false,
},
},
})
vim.cmd.colorscheme("catppuccin")

115
nvim/lua/plugins/cmp.lua Normal file
View file

@ -0,0 +1,115 @@
-- Completion plugin config
vim.opt.completeopt = 'menuone,noselect'
local cmp = require('cmp')
local cmp_kinds = {
Text = '',
Method = '󰊕 ',
Function = '󰊕 ',
Constructor = '',
Field = '',
Variable = '',
Class = '',
Interface = '',
Module = '',
Property = '',
Unit = '',
Value = '',
Enum = '',
Keyword = '',
Snippet = '',
Color = '',
File = '',
Reference = '',
Folder = '',
EnumMember = '',
Constant = '',
Struct = '',
Event = '',
Operator = '',
TypeParameter = '',
}
cmp.setup({
formatting = {
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format('%s %s', cmp_kinds[vim_item.kind], vim_item.kind)
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[LaTeX]",
})[entry.source.name]
return vim_item
end
},
snippet = {
expand = function(args)
local luasnip = require("luasnip")
if not luasnip then
return
end
luasnip.lsp_expand(args.body)
end,
},
window = {
completion = {
border = nil,
},
documentation = {
border = nil,
max_height = 2000,
}
},
completion = {
autocomplete = false,
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-x><C-o>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
-- Accept currently selected item.
-- Set `select` to `false` to only confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({ select = false }),
}),
sources = cmp.config.sources(
{
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
{
{ name = 'buffer' },
}
)
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' },
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})

View file

@ -0,0 +1,42 @@
require('gitsigns').setup {
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
end, { expr = true })
map('n', '[c', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
end, { expr = true })
-- Actions
map('n', '<leader>hs', gs.stage_hunk)
map('n', '<leader>hr', gs.reset_hunk)
map('v', '<leader>hs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end)
map('v', '<leader>hr', function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end)
map('n', '<leader>hS', gs.stage_buffer)
map('n', '<leader>hu', gs.undo_stage_hunk)
map('n', '<leader>hR', gs.reset_buffer)
map('n', '<leader>hp', gs.preview_hunk)
map('n', '<leader>hb', function() gs.blame_line { full = true } end)
map('n', '<leader>tb', gs.toggle_current_line_blame)
map('n', '<leader>hd', gs.diffthis)
map('n', '<leader>hD', function() gs.diffthis('~') end)
map('n', '<leader>td', gs.toggle_deleted)
-- Text object
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end
}

94
nvim/lua/plugins/init.lua Normal file
View file

@ -0,0 +1,94 @@
require('plugins.packer_setup')
require('packer').startup(function()
-- Packer can manage itself as an optional plugin
use { 'wbthomason/packer.nvim', opt = true }
-- Fuzzy finder
use {
'nvim-telescope/telescope.nvim',
requires = {
{ 'nvim-lua/popup.nvim' },
{ 'nvim-lua/plenary.nvim' },
}
}
-- Autocomplete and snippets
use {
'hrsh7th/nvim-cmp',
requires = {
{ 'hrsh7th/cmp-nvim-lsp' },
{ 'hrsh7th/cmp-buffer' },
{ 'hrsh7th/cmp-path' },
{ 'hrsh7th/cmp-cmdline' },
}
}
use { 'L3MON4D3/LuaSnip',
config = function()
local snippet_path = os.getenv("HOME") .. "/.config/nvim/snippets/"
if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then
vim.opt.rtp:append(snippet_path)
end
require("luasnip").config.set_config({
history = true,
updateevents = "TextChanged,TextChangedI",
delete_check_events = "TextChanged,InsertLeave",
})
require("luasnip.loaders.from_lua").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_snipmate").lazy_load()
end,
requires = {
{ "rafamadriz/friendly-snippets" },
{ 'saadparwaiz1/cmp_luasnip' },
{ "benfowler/telescope-luasnip.nvim" },
},
}
-- Statusbar, colors and syntax
use { 'vim-airline/vim-airline' }
use { 'vim-airline/vim-airline-themes' }
-- LSP and related
use { 'neovim/nvim-lspconfig' }
use { 'aznhe21/actions-preview.nvim' }
use { 'folke/trouble.nvim' } -- lsp diagnostics
-- Plugins to extend builtin language support
use { 'cespare/vim-toml' }
use { 'gleam-lang/gleam.vim' }
use { 'rust-lang/rust.vim' }
use { 'folke/neodev.nvim' }
use { 'hashivim/vim-terraform' }
-- Git
use {
'NeogitOrg/neogit',
requires = {
{ "nvim-lua/plenary.nvim" },
{ "sindrets/diffview.nvim" },
},
}
use { "lewis6991/gitsigns.nvim" }
-- Filesystem browser
use { 'stevearc/oil.nvim' }
-- Misc
use { 'jbyuki/venn.nvim' } -- ascii diagrams
use { 'hedyhli/outline.nvim' }
use { "catppuccin/nvim", as = "catppuccin" }
end)
require('plugins.catppuccin')
require('plugins.cmp')
require('plugins.gitsigns')
require('plugins.neogit')
require('plugins.oil')
require('plugins.outline')
require('plugins.telescope')
require('plugins.venn')

301
nvim/lua/plugins/neogit.lua Normal file
View file

@ -0,0 +1,301 @@
local neogit = require('neogit')
vim.keymap.set('n', '<C-S-g>', neogit.open, {})
neogit.setup {
-- Hides the hints at the top of the status buffer
disable_hint = false,
-- Disables changing the buffer highlights based on where the cursor is.
disable_context_highlighting = false,
-- Disables signs for sections/items/hunks
disable_signs = false,
-- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to
-- insert mode, and `"auto"` will change nvim to insert mode IF the commit message is empty, otherwise leaving it in
-- normal mode.
disable_insert_on_commit = "auto",
-- When enabled, will watch the `.git/` directory for changes and refresh the status buffer in response to filesystem
-- events.
filewatcher = {
interval = 1000,
enabled = true,
},
-- "ascii" is the graph the git CLI generates
-- "unicode" is the graph like https://github.com/rbong/vim-flog
graph_style = "ascii",
-- Used to generate URL's for branch popup action "pull request".
git_services = {
["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1",
["bitbucket.org"] = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1",
["gitlab.com"] = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}",
},
-- Allows a different telescope sorter. Defaults to 'fuzzy_with_index_bias'. The example below will use the native fzf
-- sorter instead. By default, this function returns `nil`.
telescope_sorter = function()
return require("telescope").extensions.fzf.native_fzf_sorter()
end,
-- Persist the values of switches/options within and across sessions
remember_settings = true,
-- Scope persisted settings on a per-project basis
use_per_project_settings = true,
-- Table of settings to never persist. Uses format "Filetype--cli-value"
ignored_settings = {
"NeogitPushPopup--force-with-lease",
"NeogitPushPopup--force",
"NeogitPullPopup--rebase",
"NeogitCommitPopup--allow-empty",
"NeogitRevertPopup--no-edit",
},
-- Configure highlight group features
highlight = {
italic = true,
bold = true,
underline = true
},
-- Set to false if you want to be responsible for creating _ALL_ keymappings
use_default_keymaps = true,
-- Neogit refreshes its internal state after specific events, which can be expensive depending on the repository size.
-- Disabling `auto_refresh` will make it so you have to manually refresh the status after you open it.
auto_refresh = true,
-- Value used for `--sort` option for `git branch` command
-- By default, branches will be sorted by commit date descending
-- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt
-- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options
sort_branches = "-committerdate",
-- Change the default way of opening neogit
kind = "tab",
-- Disable line numbers and relative line numbers
disable_line_numbers = true,
-- The time after which an output console is shown for slow running commands
console_timeout = 2000,
-- Automatically show console if a command takes more than console_timeout milliseconds
auto_show_console = true,
-- Automatically close the console if the process exits with a 0 (success) status
auto_close_console = true,
status = {
show_head_commit_hash = true,
recent_commit_count = 10,
HEAD_padding = 10,
HEAD_folded = false,
mode_padding = 3,
mode_text = {
M = "modified",
N = "new file",
A = "added",
D = "deleted",
C = "copied",
U = "updated",
R = "renamed",
DD = "unmerged",
AU = "unmerged",
UD = "unmerged",
UA = "unmerged",
DU = "unmerged",
AA = "unmerged",
UU = "unmerged",
["?"] = "",
},
},
commit_editor = {
kind = "tab",
show_staged_diff = true,
-- Accepted values:
-- "split" to show the staged diff below the commit editor
-- "vsplit" to show it to the right
-- "split_above" Like :top split
-- "vsplit_left" like :vsplit, but open to the left
-- "auto" "vsplit" if window would have 80 cols, otherwise "split"
staged_diff_split_kind = "split"
},
commit_select_view = {
kind = "tab",
},
commit_view = {
kind = "vsplit",
verify_commit = vim.fn.executable("gpg") == 1, -- Can be set to true or false, otherwise we try to find the binary
},
log_view = {
kind = "tab",
},
rebase_editor = {
kind = "auto",
},
reflog_view = {
kind = "tab",
},
merge_editor = {
kind = "auto",
},
tag_editor = {
kind = "auto",
},
preview_buffer = {
kind = "split",
},
popup = {
kind = "split",
},
signs = {
-- { CLOSED, OPENED }
hunk = { "", "" },
item = { ">", "v" },
section = { ">", "v" },
},
-- Each Integration is auto-detected through plugin presence, however, it can be disabled by setting to `false`
integrations = {
-- If enabled, use telescope for menu selection rather than vim.ui.select.
-- Allows multi-select and some things that vim.ui.select doesn't.
telescope = true,
-- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `diffview`.
-- The diffview integration enables the diff popup.
--
-- Requires you to have `sindrets/diffview.nvim` installed.
diffview = true,
-- If enabled, uses fzf-lua for menu selection. If the telescope integration
-- is also selected then telescope is used instead
-- Requires you to have `ibhagwan/fzf-lua` installed.
fzf_lua = true,
},
sections = {
-- Reverting/Cherry Picking
sequencer = {
folded = false,
hidden = false,
},
untracked = {
folded = false,
hidden = false,
},
unstaged = {
folded = false,
hidden = false,
},
staged = {
folded = false,
hidden = false,
},
stashes = {
folded = true,
hidden = false,
},
unpulled_upstream = {
folded = true,
hidden = false,
},
unmerged_upstream = {
folded = false,
hidden = false,
},
unpulled_pushRemote = {
folded = true,
hidden = false,
},
unmerged_pushRemote = {
folded = false,
hidden = false,
},
recent = {
folded = true,
hidden = false,
},
rebase = {
folded = true,
hidden = false,
},
},
mappings = {
commit_editor = {
["q"] = "Close",
["<c-c><c-c>"] = "Submit",
["<c-c><c-k>"] = "Abort",
},
commit_editor_I = {
["<c-c><c-c>"] = "Submit",
["<c-c><c-k>"] = "Abort",
},
rebase_editor = {
["p"] = "Pick",
["r"] = "Reword",
["e"] = "Edit",
["s"] = "Squash",
["f"] = "Fixup",
["x"] = "Execute",
["d"] = "Drop",
["b"] = "Break",
["q"] = "Close",
["<cr>"] = "OpenCommit",
["gk"] = "MoveUp",
["gj"] = "MoveDown",
["<c-c><c-c>"] = "Submit",
["<c-c><c-k>"] = "Abort",
["[c"] = "OpenOrScrollUp",
["]c"] = "OpenOrScrollDown",
},
rebase_editor_I = {
["<c-c><c-c>"] = "Submit",
["<c-c><c-k>"] = "Abort",
},
finder = {
["<cr>"] = "Select",
["<c-c>"] = "Close",
["<esc>"] = "Close",
["<c-n>"] = "Next",
["<c-p>"] = "Previous",
["<down>"] = "Next",
["<up>"] = "Previous",
["<tab>"] = "MultiselectToggleNext",
["<s-tab>"] = "MultiselectTogglePrevious",
["<c-j>"] = "NOP",
},
-- Setting any of these to `false` will disable the mapping.
popup = {
["?"] = "HelpPopup",
["A"] = "CherryPickPopup",
["D"] = "DiffPopup",
["M"] = "RemotePopup",
["P"] = "PushPopup",
["X"] = "ResetPopup",
["Z"] = "StashPopup",
["b"] = "BranchPopup",
["B"] = "BisectPopup",
["c"] = "CommitPopup",
["f"] = "FetchPopup",
["l"] = "LogPopup",
["m"] = "MergePopup",
["p"] = "PullPopup",
["r"] = "RebasePopup",
["v"] = "RevertPopup",
["w"] = "WorktreePopup",
},
status = {
["k"] = "MoveUp",
["j"] = "MoveDown",
["q"] = "Close",
["o"] = "OpenTree",
["I"] = "InitRepo",
["1"] = "Depth1",
["2"] = "Depth2",
["3"] = "Depth3",
["4"] = "Depth4",
["<tab>"] = "Toggle",
["x"] = "Discard",
["s"] = "Stage",
["S"] = "StageUnstaged",
["<c-s>"] = "StageAll",
["K"] = "Untrack",
["u"] = "Unstage",
["U"] = "UnstageStaged",
["$"] = "CommandHistory",
["Y"] = "YankSelected",
["<c-r>"] = "RefreshBuffer",
["<enter>"] = "GoToFile",
["<c-v>"] = "VSplitOpen",
["<c-x>"] = "SplitOpen",
["<c-t>"] = "TabOpen",
["{"] = "GoToPreviousHunkHeader",
["}"] = "GoToNextHunkHeader",
["[c"] = "OpenOrScrollUp",
["]c"] = "OpenOrScrollDown",
},
},
}

164
nvim/lua/plugins/oil.lua Normal file
View file

@ -0,0 +1,164 @@
local git_ignored = setmetatable({}, {
__index = function(self, key)
local proc = vim.system(
{ "git", "ls-files", "--ignored", "--exclude-standard", "--others", "--directory" },
{
cwd = key,
text = true,
}
)
local result = proc:wait()
local ret = {}
if result.code == 0 then
for line in vim.gsplit(result.stdout, "\n", { plain = true, trimempty = true }) do
-- Remove trailing slash
line = line:gsub("/$", "")
table.insert(ret, line)
end
end
rawset(self, key, ret)
return ret
end,
})
require('oil').setup({
default_file_explorer = true,
-- Id is automatically added at the beginning, and name at the end
-- See :help oil-columns
columns = {
"icon",
-- "permissions",
-- "size",
-- "mtime",
},
-- Buffer-local options to use for oil buffers
buf_options = {
buflisted = false,
bufhidden = "hide",
},
-- Window-local options to use for oil buffers
win_options = {
wrap = false,
signcolumn = "no",
cursorcolumn = false,
foldcolumn = "0",
spell = false,
list = false,
conceallevel = 3,
concealcursor = "nvic",
},
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
delete_to_trash = false,
-- Skip the confirmation popup for simple operations
skip_confirm_for_simple_edits = false,
-- Change this to customize the command used when deleting to trash
trash_command = "trash-put",
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first
prompt_save_on_select_new_entry = true,
-- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap
-- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true })
-- Additionally, if it is a string that matches "actions.<name>",
-- it will use the mapping at require("oil.actions").<name>
-- Set to `false` to remove a keymap
-- See :help oil-actions for a list of all available actions
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-s>"] = "actions.select_vsplit",
["<C-h>"] = "actions.select_split",
["<C-t>"] = "actions.select_tab",
["<C-p>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-l>"] = "actions.refresh",
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = "actions.tcd",
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
},
-- Set to false to disable all of the above keymaps
use_default_keymaps = true,
view_options = {
-- Show files and directories that start with "."
show_hidden = true,
-- This function defines what is considered a "hidden" file
is_hidden_file = function(name, _)
if vim.startswith(name, ".") then
return true
end
local dir = require("oil").get_current_dir()
-- if no local directory (e.g. for ssh connections), always show
if not dir then
return false
end
-- return vim.list_contains(git_ignored[dir], name)
end,
-- This function defines what will never be shown, even when `show_hidden` is set
is_always_hidden = function(name, bufnr)
return false
end,
sort = {
-- sort order can be "asc" or "desc"
-- see :help oil-columns to see which columns are sortable
{ "type", "asc" },
{ "name", "asc" },
},
},
-- Configuration for the floating window in oil.open_float
float = {
-- Padding around the floating window
padding = 2,
max_width = 0,
max_height = 0,
border = "rounded",
win_options = {
winblend = 0,
},
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
override = function(conf)
return conf
end,
},
-- Configuration for the actions floating preview window
preview = {
-- Width dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- min_width and max_width can be a single value or a list of mixed integer/float types.
-- max_width = {100, 0.8} means "the lesser of 100 columns or 80% of total"
max_width = 0.9,
-- min_width = {40, 0.4} means "the greater of 40 columns or 40% of total"
min_width = { 40, 0.4 },
-- optionally define an integer/float for the exact width of the preview window
width = nil,
-- Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- min_height and max_height can be a single value or a list of mixed integer/float types.
-- max_height = {80, 0.9} means "the lesser of 80 columns or 90% of total"
max_height = 0.9,
-- min_height = {5, 0.1} means "the greater of 5 columns or 10% of total"
min_height = { 5, 0.1 },
-- optionally define an integer/float for the exact height of the preview window
height = nil,
border = "rounded",
win_options = {
winblend = 0,
},
},
-- Configuration for the floating progress window
progress = {
max_width = 0.9,
min_width = { 40, 0.4 },
width = nil,
max_height = { 10, 0.9 },
min_height = { 5, 0.1 },
height = nil,
border = "rounded",
minimized_border = "none",
win_options = {
winblend = 0,
},
},
})

View file

@ -0,0 +1,137 @@
require("outline").setup({
guides = {
enabled = true,
markers = {
bottom = '',
middle = '',
vertical = '',
horizontal = '',
},
},
outline_items = {
show_symbol_details = true,
show_symbol_lineno = false,
-- The two below are both for auto_update_events.follow
highlight_hovered_item = true,
-- On open, always followed. This is for auto_update_events.follow, whether
-- to auto update cursor position to reflect code location. If false, can
-- manually trigger with follow_cursor (API, command, keymap action).
auto_set_cursor = true,
auto_update_events = {
follow = { 'CursorMoved' },
items = { 'InsertLeave', 'WinEnter', 'BufEnter', 'BufWinEnter', 'BufWritePost' },
},
},
outline_window = {
position = 'right',
split_command = nil,
width = 25,
relative_width = true,
wrap = false,
focus_on_open = true,
auto_close = false,
auto_jump = false,
show_numbers = false,
show_relative_numbers = false,
---@type boolean|string?
show_cursorline = true,
hide_cursor = false,
winhl = '',
jump_highlight_duration = 400,
center_on_jump = true,
},
preview_window = {
live = false,
auto_preview = false,
width = 50,
min_width = 50,
relative_width = true,
height = 50,
min_height = 10,
relative_height = true,
border = 'single',
open_hover_on_preview = false,
winhl = 'NormalFloat:',
winblend = 0,
},
symbol_folding = {
autofold_depth = 1,
auto_unfold = {
hovered = true,
---@type boolean|integer
only = true,
},
markers = { '', '' },
},
keymaps = {
show_help = '?',
close = { '<Esc>', 'q' },
goto_location = '<Cr>',
peek_location = 'o',
goto_and_close = '<S-Cr>',
restore_location = '<C-g>',
hover_symbol = '<C-space>',
toggle_preview = 'K',
rename_symbol = 'r',
code_actions = 'a',
fold = 'h',
fold_toggle = '<tab>',
fold_toggle_all = '<S-tab>',
unfold = 'l',
fold_all = 'W',
unfold_all = 'E',
fold_reset = 'R',
down_and_jump = '<C-j>',
up_and_jump = '<C-k>',
},
providers = {
priority = { 'lsp', 'coc', 'markdown', 'norg' },
lsp = {
blacklist_clients = {},
},
markdown = {
filetypes = { 'markdown' },
},
},
symbols = {
---@type outline.FilterConfig?
filter = nil,
icon_source = nil,
icon_fetcher = nil,
icons = {
File = { icon = '', hl = 'Identifier' },
Module = { icon = '', hl = 'Include' },
Namespace = { icon = '{}', hl = 'Include' },
Package = { icon = '', hl = 'Include' },
Class = { icon = '𝓒', hl = 'Type' },
Method = { icon = '', hl = 'Function' },
Property = { icon = '', hl = 'Identifier' },
Field = { icon = '-', hl = 'Identifier' },
Constructor = { icon = '()', hl = 'Special' },
Enum = { icon = '', hl = 'Type' },
Interface = { icon = 'i', hl = 'Type' },
Function = { icon = 'ƒ', hl = 'Function' },
Variable = { icon = '(x)', hl = 'Constant' },
Constant = { icon = 'c', hl = 'Constant' },
String = { icon = '𝓐', hl = 'String' },
Number = { icon = '#', hl = 'Number' },
Boolean = { icon = '', hl = 'Boolean' },
Array = { icon = '[]', hl = 'Constant' },
Object = { icon = '⦿', hl = 'Type' },
Key = { icon = '🔐', hl = 'Type' },
Null = { icon = 'NULL', hl = 'Type' },
EnumMember = { icon = '', hl = 'Identifier' },
Struct = { icon = '𝓢', hl = 'Structure' },
Event = { icon = '🗲', hl = 'Type' },
Operator = { icon = '+', hl = 'Identifier' },
TypeParameter = { icon = '𝙏', hl = 'Identifier' },
Component = { icon = '', hl = 'Function' },
Fragment = { icon = '-', hl = 'Constant' },
-- ccls
TypeAlias = { icon = 't ', hl = 'Type' },
Parameter = { icon = 'p ', hl = 'Identifier' },
StaticMethod = { icon = '. ', hl = 'Function' },
Macro = { icon = '', hl = 'Function' },
},
},
})

View file

@ -0,0 +1,9 @@
-- Auto install packer.nvim if not exists
local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.api.nvim_command('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
end
vim.cmd [[packadd packer.nvim]]
-- Auto compile when there are changes in plugins.lua
vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile'

View file

@ -0,0 +1,62 @@
local telescope = require('telescope')
local actions = require('telescope.actions')
local builtin = require('telescope.builtin')
local telescope_last = 0
function telescope_resume()
if telescope_last == 0 then
telescope_last = 1
builtin.live_grep()
else
builtin.resume()
end
end
telescope.setup {
defaults = {
sorting_strategy = "ascending",
live_grep_arguments = { 'rg',
'--hidden', '--no-ignore', '--color=never',
'--with-filename', '--line-number',
'--column', '--smart-case', '--no-heading',
},
preview = {
treesitter = false
},
},
pickers = {
live_grep = {
mappings = {
i = { ["<c-f>"] = actions.to_fuzzy_refine },
n = { ["<c-f>"] = telescope_resume },
},
},
find_files = {
cache_picker = false,
},
git_files = {
cache_picker = false,
},
},
}
-- Snippets can be useful.
vim.keymap.set('n', '<leader>ss', telescope.extensions.luasnip.luasnip, {})
-- Fuzzy * files, symbols, buffers, help, etc.
vim.keymap.set('n', '<leader>fa', builtin.find_files) -- f[ind]a[ll]
vim.keymap.set('n', '<leader>fb', builtin.buffers)
vim.keymap.set('n', '<leader>fd', builtin.diagnostics)
vim.keymap.set('n', '<leader>ff', builtin.git_files)
vim.keymap.set('n', '<leader>fh', builtin.help_tags)
vim.keymap.set('n', '<leader>fs', builtin.lsp_dynamic_workspace_symbols)
-- Grep (the only one).
vim.keymap.set('n', '<leader>gg', builtin.live_grep)
-- LSP navigation.
vim.keymap.set('n', '<leader>gd', builtin.lsp_definitions)
vim.keymap.set('n', '<leader>gr', builtin.lsp_references)
vim.keymap.set('n', '<leader>gi', builtin.lsp_implementations)
vim.keymap.set('n', '<leader>ci', builtin.lsp_incoming_calls)
vim.keymap.set('n', '<leader>co', builtin.lsp_outgoing_calls)

22
nvim/lua/plugins/venn.lua Normal file
View file

@ -0,0 +1,22 @@
-- venn.nvim: enable or disable keymappings
function _G.Toggle_venn()
local venn_enabled = vim.inspect(vim.b.venn_enabled)
if venn_enabled == "nil" then
vim.b.venn_enabled = true
vim.cmd [[setlocal ve=all]]
-- draw a line on HJKL keystokes
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
-- draw a box by pressing "f" with visual selection
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true })
else
vim.cmd [[setlocal ve=]]
vim.cmd [[mapclear <buffer>]]
vim.b.venn_enabled = nil
end
end
-- toggle keymappings for venn using <leader>v
vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true })