417 lines
12 KiB
Lua
417 lines
12 KiB
Lua
local deps = require("nvim-deps")
|
|
vim.opt.termguicolors = true
|
|
vim.notify = require("notify")
|
|
vim.notify.setup({background_colour = "#000000"})
|
|
require("oil").setup()
|
|
require("dressing").setup({
|
|
input = {
|
|
-- Set to false to disable the vim.ui.input implementation
|
|
enabled = true,
|
|
|
|
-- Default prompt string
|
|
default_prompt = "Input",
|
|
|
|
-- Trim trailing `:` from prompt
|
|
trim_prompt = true,
|
|
|
|
-- Can be 'left', 'right', or 'center'
|
|
title_pos = "left",
|
|
|
|
-- When true, <Esc> will close the modal
|
|
insert_only = true,
|
|
|
|
-- When true, input will start in insert mode.
|
|
start_in_insert = true,
|
|
|
|
-- These are passed to nvim_open_win
|
|
border = "rounded",
|
|
-- 'editor' and 'win' will default to being centered
|
|
relative = "cursor",
|
|
|
|
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
|
|
prefer_width = 40,
|
|
width = nil,
|
|
-- min_width and max_width can be a list of mixed types.
|
|
-- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total"
|
|
max_width = { 140, 0.9 },
|
|
min_width = { 20, 0.2 },
|
|
|
|
buf_options = {},
|
|
win_options = {
|
|
-- Disable line wrapping
|
|
wrap = false,
|
|
-- Indicator for when text exceeds window
|
|
list = true,
|
|
listchars = "precedes:…,extends:…",
|
|
-- Increase this for more context when text scrolls off the window
|
|
sidescrolloff = 0,
|
|
},
|
|
|
|
-- Set to `false` to disable
|
|
mappings = {
|
|
n = {
|
|
["<Esc>"] = "Close",
|
|
["<CR>"] = "Confirm",
|
|
},
|
|
i = {
|
|
["<C-c>"] = "Close",
|
|
["<CR>"] = "Confirm",
|
|
["<Up>"] = "HistoryPrev",
|
|
["<Down>"] = "HistoryNext",
|
|
},
|
|
},
|
|
|
|
override = function(conf)
|
|
-- This is the config that will be passed to nvim_open_win.
|
|
-- Change values here to customize the layout
|
|
return conf
|
|
end,
|
|
|
|
-- see :help dressing_get_config
|
|
get_config = nil,
|
|
},
|
|
select = {
|
|
-- Set to false to disable the vim.ui.select implementation
|
|
enabled = true,
|
|
|
|
-- Priority list of preferred vim.select implementations
|
|
backend = { "builtin" },
|
|
|
|
-- Trim trailing `:` from prompt
|
|
trim_prompt = true,
|
|
|
|
-- Options for telescope selector
|
|
-- These are passed into the telescope picker directly. Can be used like:
|
|
-- telescope = require('telescope.themes').get_ivy({...})
|
|
telescope = nil,
|
|
|
|
-- Options for fzf selector
|
|
fzf = {
|
|
window = {
|
|
width = 0.5,
|
|
height = 0.4,
|
|
},
|
|
},
|
|
|
|
-- Options for fzf-lua
|
|
fzf_lua = {
|
|
-- winopts = {
|
|
-- height = 0.5,
|
|
-- width = 0.5,
|
|
-- },
|
|
},
|
|
|
|
-- Options for nui Menu
|
|
nui = {
|
|
position = "50%",
|
|
size = nil,
|
|
relative = "editor",
|
|
border = {
|
|
style = "rounded",
|
|
},
|
|
buf_options = {
|
|
swapfile = false,
|
|
filetype = "DressingSelect",
|
|
},
|
|
win_options = {
|
|
winblend = 0,
|
|
},
|
|
max_width = 80,
|
|
max_height = 40,
|
|
min_width = 40,
|
|
min_height = 10,
|
|
},
|
|
|
|
-- Options for built-in selector
|
|
builtin = {
|
|
-- Display numbers for options and set up keymaps
|
|
show_numbers = true,
|
|
-- These are passed to nvim_open_win
|
|
border = "rounded",
|
|
-- 'editor' and 'win' will default to being centered
|
|
relative = "editor",
|
|
|
|
buf_options = {},
|
|
win_options = {
|
|
cursorline = true,
|
|
cursorlineopt = "both",
|
|
},
|
|
|
|
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
|
|
-- the min_ and max_ options can be a list of mixed types.
|
|
-- max_width = {140, 0.8} means "the lesser of 140 columns or 80% of total"
|
|
width = nil,
|
|
max_width = { 140, 0.8 },
|
|
min_width = { 40, 0.2 },
|
|
height = nil,
|
|
max_height = 0.9,
|
|
min_height = { 10, 0.2 },
|
|
|
|
-- Set to `false` to disable
|
|
mappings = {
|
|
["<Esc>"] = "Close",
|
|
["<C-c>"] = "Close",
|
|
["<CR>"] = "Confirm",
|
|
},
|
|
|
|
override = function(conf)
|
|
-- This is the config that will be passed to nvim_open_win.
|
|
-- Change values here to customize the layout
|
|
return conf
|
|
end,
|
|
},
|
|
|
|
-- Used to override format_item. See :help dressing-format
|
|
format_item_override = {},
|
|
|
|
-- see :help dressing_get_config
|
|
get_config = nil,
|
|
},
|
|
})
|
|
local telescope = require('telescope.builtin')
|
|
vim.keymap.set('n', '<leader>ff', telescope.find_files, {})
|
|
vim.keymap.set('n', '<leader>fg', telescope.live_grep, {})
|
|
vim.keymap.set('n', '<leader>fb', telescope.buffers, {})
|
|
vim.keymap.set('n', '<leader>fh', telescope.help_tags, {})
|
|
require("telescope").setup({
|
|
defaults = {
|
|
mappings = {
|
|
i = {
|
|
["<cr>"] = function(bufnr)
|
|
require("telescope.actions.set").edit(bufnr, "tab drop")
|
|
end
|
|
}
|
|
}
|
|
},
|
|
extensions = {
|
|
undo = {
|
|
side_by_side = true,
|
|
layout_strategy = "vertical",
|
|
layout_config = {preview_height = 0.8}
|
|
},
|
|
}
|
|
|
|
})
|
|
require('telescope').load_extension("undo")
|
|
require("telescope").load_extension("ui-select")
|
|
local neogit = require('neogit')
|
|
-- git commit
|
|
-- vim.keymap.set('n', '<leader>gc', neogit.open, { "commit" })
|
|
-- git neo -> Neogit
|
|
vim.keymap.set('n', '<leader>gN', neogit.open, {})
|
|
neogit.setup({
|
|
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}",
|
|
["apps.terminal"] = "http://apps.terminal/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}"
|
|
},
|
|
status = {
|
|
recent_commit_count = 100,
|
|
},
|
|
integrations = {
|
|
diffview = true,
|
|
telescope = true,
|
|
fzf_lua = true,
|
|
},
|
|
mappings = {
|
|
commit_editor = {
|
|
["q"] = "Close",
|
|
["<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",
|
|
},
|
|
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",
|
|
["c"] = "CommitPopup",
|
|
["f"] = "FetchPopup",
|
|
["l"] = "LogPopup",
|
|
["m"] = "MergePopup",
|
|
["p"] = "PullPopup",
|
|
["r"] = "RebasePopup",
|
|
["v"] = "RevertPopup",
|
|
},
|
|
status = {
|
|
["q"] = "Close",
|
|
["I"] = "InitRepo",
|
|
["1"] = "Depth1",
|
|
["2"] = "Depth2",
|
|
["3"] = "Depth3",
|
|
["4"] = "Depth4",
|
|
["<tab>"] = "Toggle",
|
|
["x"] = "Discard",
|
|
["s"] = "Stage",
|
|
["S"] = "StageUnstaged",
|
|
["<c-s>"] = "StageAll",
|
|
["u"] = "Unstage",
|
|
["U"] = "UnstageStaged",
|
|
["$"] = "CommandHistory",
|
|
["#"] = "Console",
|
|
["Y"] = "YankSelected",
|
|
["<c-r>"] = "RefreshBuffer",
|
|
["<enter>"] = "GoToFile",
|
|
["<c-v>"] = "VSplitOpen",
|
|
["<c-x>"] = "SplitOpen",
|
|
["<c-t>"] = "TabOpen",
|
|
["{"] = "GoToPreviousHunkHeader",
|
|
["}"] = "GoToNextHunkHeader",
|
|
},
|
|
},
|
|
})
|
|
require('gitblame').setup {
|
|
-- Note how the `gitblame_` prefix is omitted in `setup`
|
|
enabled = true,
|
|
delay = 1000,
|
|
highlight_group = "NeogitGraphGray"
|
|
}
|
|
local dap, dapui = require("dap"), require("dapui")
|
|
dap.adapters.lldb = {
|
|
type = "executable",
|
|
command = deps.lldb_path .. "/bin/lldb-vscode",
|
|
name = "lldb"
|
|
}
|
|
local dap_breakpoint = {
|
|
error = {
|
|
text = "🟥",
|
|
texthl = "LspDiagnosticsSignError",
|
|
linehl = "",
|
|
numhl = ""
|
|
},
|
|
rejected = {
|
|
text = "❗",
|
|
texthl = "LspDiagnosticsSignHint",
|
|
linehl = "",
|
|
numhl = ""
|
|
},
|
|
stopped = {
|
|
text = "🛑",
|
|
texthl = "LspDiagnosticsSignInformation",
|
|
linehl = "DiagnosticUnderlineInfo",
|
|
numhl = "LspDiagnosticsSignInformation"
|
|
}
|
|
}
|
|
|
|
vim.keymap.set('n', '<leader>dk', function() dap.continue() end)
|
|
vim.keymap.set('n', '<leader>dl', function() dap.run_last() end)
|
|
vim.keymap.set('n', '<leader>b', function() dap.toggle_breakpoint() end)
|
|
vim.fn.sign_define("DapBreakpoint", dap_breakpoint.error)
|
|
vim.fn.sign_define("DapStopped", dap_breakpoint.stopped)
|
|
vim.fn.sign_define("DapBreakpointRejected", dap_breakpoint.rejected)
|
|
|
|
dapui.setup()
|
|
|
|
-- Auto open and close dapUI
|
|
dap.listeners.after.event_initialized["dapui_config"] =
|
|
function() dapui.open() end
|
|
dap.listeners.before.event_terminated["dapui_config"] =
|
|
function() dapui.close() end
|
|
dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end
|
|
|
|
-- Setup language servers.
|
|
local lspconfig = require('lspconfig')
|
|
-- Global mappings.
|
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
|
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
|
|
|
|
-- Use LspAttach autocommand to only map the following keys
|
|
-- after the language server attaches to the current buffer
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
|
callback = function(ev)
|
|
-- Enable completion triggered by <c-x><c-o>
|
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
|
|
|
-- Buffer local mappings.
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
local opts = {buffer = ev.buf}
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
|
vim.keymap
|
|
.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
|
|
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder,
|
|
opts)
|
|
vim.keymap.set('n', '<leader>wl', function()
|
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
end, opts)
|
|
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
vim.keymap.set({'n', 'v'}, '<leader>ca', vim.lsp.buf.code_action, opts)
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
|
vim.keymap.set('n', '<leader>F', vim.lsp.buf.format, opts)
|
|
end
|
|
})
|
|
|
|
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
|
-- deps.typst-lsp_path
|
|
lspconfig.typst_lsp.setup {
|
|
cmd = {(deps["typst-lsp_path"] .. "/bin/typst-lsp")},
|
|
settings = {
|
|
exportPdf = "onType", -- Choose onType, onSave or never.
|
|
serverPath = (deps["typst-lsp_path"] .. "/bin/typst-lsp"), -- Normally, there is no need to uncomment it.
|
|
}
|
|
}
|
|
lspconfig.nil_ls.setup {
|
|
cmd = {(deps["nil_path"] .. "/bin/nil")},
|
|
-- https://github.com/oxalica/nil/blob/main/docs/configuration.md
|
|
settings = {
|
|
command = {
|
|
formatting = "nixpkgs-fmt", },
|
|
},
|
|
flake = {
|
|
autoArchive = true,
|
|
autoEvalInputs = true,
|
|
},
|
|
}
|
|
require('neotest').setup {
|
|
-- ...,
|
|
adapters = {
|
|
-- ...,
|
|
require('rustaceanvim.neotest')
|
|
},
|
|
}
|
|
require("lsp-inlayhints").setup()
|
|
require("completion")
|
|
require("rust")
|
|
require("debugger")
|