242 lines
8.0 KiB
Lua
242 lines
8.0 KiB
Lua
local deps = require("nvim-deps")
|
|
vim.opt.termguicolors = true
|
|
vim.notify = require("notify")
|
|
vim.notify.setup({background_colour = "#000000"})
|
|
require("oil").setup()
|
|
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")
|
|
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("lsp-inlayhints").setup()
|
|
require("completion")
|