832 lines
22 KiB
Lua
832 lines
22 KiB
Lua
------------------------------------------------------------------------------
|
||
-- Bootstrap
|
||
-------------------------------------------------------------------------------
|
||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||
if not vim.loop.fs_stat(lazypath) then
|
||
vim.fn.system({
|
||
"git",
|
||
"clone",
|
||
"--filter=blob:none",
|
||
"https://github.com/folke/lazy.nvim.git",
|
||
"--branch=stable",
|
||
lazypath,
|
||
})
|
||
end
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Basic settings
|
||
-------------------------------------------------------------------------------
|
||
vim.opt.exrc = true
|
||
vim.opt.autoread = true
|
||
vim.opt.rtp:prepend(lazypath)
|
||
vim.g.mapleader = " "
|
||
vim.opt.termguicolors = true
|
||
vim.opt.cursorline = true
|
||
vim.o.background = "dark"
|
||
vim.opt.updatetime = 1000
|
||
vim.opt.signcolumn = "yes"
|
||
vim.opt.colorcolumn = "80"
|
||
vim.g.loaded_netrw = 1
|
||
vim.g.loaded_netrwPlugin = 1
|
||
vim.wo.number = true
|
||
vim.opt.shortmess:append("sI")
|
||
vim.opt.wrap = false
|
||
vim.opt.title = true
|
||
vim.opt.titlestring = [[%{fnamemodify(getcwd(), ':t')}]]
|
||
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
|
||
vim.g.clipboard = {
|
||
name = 'OSC 52',
|
||
copy = {
|
||
['+'] = require('vim.ui.clipboard.osc52').copy('+'),
|
||
['*'] = require('vim.ui.clipboard.osc52').copy('*'),
|
||
},
|
||
paste = {
|
||
['+'] = require('vim.ui.clipboard.osc52').paste('+'),
|
||
['*'] = require('vim.ui.clipboard.osc52').paste('*'),
|
||
},
|
||
}
|
||
|
||
if vim.g.vscode then
|
||
require("lazy").setup({
|
||
{
|
||
"terrortylor/nvim-comment",
|
||
config = function()
|
||
require("nvim_comment").setup()
|
||
end
|
||
},
|
||
{
|
||
"kylechui/nvim-surround",
|
||
version = "*",
|
||
event = "VeryLazy",
|
||
opts = {}
|
||
},
|
||
})
|
||
local vscode = require('vscode')
|
||
|
||
local opts = { noremap = true, silent = true }
|
||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||
vim.keymap.set('n', 'gd', function()
|
||
vscode.call("editor.action.revealDefinition")
|
||
end, opts)
|
||
vim.keymap.set('n', '<A-c>', function()
|
||
vscode.call("workbench.action.closeActiveEditor")
|
||
end, 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', 'gr', vim.lsp.buf.references, opts)
|
||
vim.keymap.set('n', '<leader>k', vim.diagnostic.open_float, opts)
|
||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
|
||
vim.keymap.set('n', '<leader>ca', function()
|
||
vscode.call("editor.action.quickFix")
|
||
end
|
||
, opts)
|
||
return
|
||
end
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Plugins
|
||
-------------------------------------------------------------------------------
|
||
require("lazy").setup({
|
||
{
|
||
"folke/zen-mode.nvim",
|
||
opts = {
|
||
window = {
|
||
options = {
|
||
number = false
|
||
}
|
||
|
||
}
|
||
}
|
||
},
|
||
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
|
||
{
|
||
"benlubas/molten-nvim",
|
||
version = "^1.0.0",
|
||
build = ":UpdateRemotePlugins",
|
||
init = function()
|
||
vim.g.molten_output_win_max_height = 12
|
||
end,
|
||
},
|
||
{
|
||
'rmagatti/auto-session',
|
||
lazy = false,
|
||
opts = {
|
||
save_extra_data = function(_)
|
||
local ok, breakpoints = pcall(require, "dap.breakpoints")
|
||
if not ok or not breakpoints then
|
||
return
|
||
end
|
||
|
||
local bps = {}
|
||
local breakpoints_by_buf = breakpoints.get()
|
||
for buf, buf_bps in pairs(breakpoints_by_buf) do
|
||
bps[vim.api.nvim_buf_get_name(buf)] = buf_bps
|
||
end
|
||
if vim.tbl_isempty(bps) then
|
||
return
|
||
end
|
||
local extra_data = {
|
||
breakpoints = bps,
|
||
}
|
||
return vim.fn.json_encode(extra_data)
|
||
end,
|
||
|
||
restore_extra_data = function(_, extra_data)
|
||
local json = vim.fn.json_decode(extra_data)
|
||
|
||
if json.breakpoints then
|
||
local ok, breakpoints = pcall(require, "dap.breakpoints")
|
||
|
||
if not ok or not breakpoints then
|
||
return
|
||
end
|
||
vim.notify("restoring breakpoints")
|
||
for buf_name, buf_bps in pairs(json.breakpoints) do
|
||
for _, bp in pairs(buf_bps) do
|
||
local line = bp.line
|
||
local opts = {
|
||
condition = bp.condition,
|
||
log_message = bp.logMessage,
|
||
hit_condition = bp.hitCondition,
|
||
}
|
||
|
||
local bufnr = vim.fn.bufnr(buf_name, true)
|
||
if vim.fn.bufloaded(bufnr) == 0 then
|
||
vim.api.nvim_buf_call(bufnr, vim.cmd.edit)
|
||
end
|
||
|
||
breakpoints.set(opts, bufnr, line)
|
||
end
|
||
end
|
||
end
|
||
end,
|
||
}
|
||
},
|
||
{
|
||
"williamboman/mason.nvim",
|
||
opts = {}
|
||
},
|
||
"rcarriga/nvim-notify",
|
||
{
|
||
'windwp/nvim-autopairs',
|
||
event = "InsertEnter",
|
||
config = true
|
||
},
|
||
'hrsh7th/cmp-nvim-lsp',
|
||
'hrsh7th/cmp-buffer',
|
||
'hrsh7th/cmp-path',
|
||
'hrsh7th/cmp-cmdline',
|
||
'hrsh7th/nvim-cmp',
|
||
'hrsh7th/cmp-vsnip',
|
||
'hrsh7th/vim-vsnip',
|
||
"neovim/nvim-lspconfig",
|
||
"nvimtools/none-ls.nvim",
|
||
{
|
||
"NeogitOrg/neogit",
|
||
dependencies = {
|
||
"nvim-lua/plenary.nvim",
|
||
"sindrets/diffview.nvim",
|
||
"nvim-telescope/telescope.nvim",
|
||
},
|
||
},
|
||
{
|
||
"nvim-tree/nvim-tree.lua",
|
||
opts = {
|
||
filters = {
|
||
custom = { "\\.uid$" }
|
||
}
|
||
},
|
||
init = function()
|
||
vim.keymap.set('n', '<leader>tt', require("nvim-tree.api").tree.toggle)
|
||
vim.keymap.set('n', '<leader>tf', require("nvim-tree.api").tree.find_file)
|
||
end
|
||
|
||
},
|
||
{
|
||
"kylechui/nvim-surround",
|
||
version = "*",
|
||
event = "VeryLazy",
|
||
opts = {}
|
||
},
|
||
{
|
||
'nvim-telescope/telescope.nvim',
|
||
tag = '0.1.6',
|
||
dependencies = {
|
||
'nvim-lua/plenary.nvim',
|
||
}
|
||
},
|
||
{
|
||
'romgrk/barbar.nvim',
|
||
dependencies = {
|
||
'lewis6991/gitsigns.nvim',
|
||
'nvim-tree/nvim-web-devicons',
|
||
},
|
||
init = function() vim.g.barbar_auto_setup = false end,
|
||
opts = {
|
||
icons = {
|
||
pinned = { button = '', filename = true },
|
||
}
|
||
|
||
},
|
||
version = '^1.0.0',
|
||
},
|
||
{
|
||
"lewis6991/gitsigns.nvim",
|
||
opts = {
|
||
current_line_blame = true,
|
||
numhl = true,
|
||
linehl = true,
|
||
word_diff = true,
|
||
on_attach = function(bufnr)
|
||
local gitsigns = require('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
|
||
vim.cmd.normal({ ']c', bang = true })
|
||
else
|
||
gitsigns.nav_hunk('next')
|
||
end
|
||
end)
|
||
map('n', '[c', function()
|
||
if vim.wo.diff then
|
||
vim.cmd.normal({ '[c', bang = true })
|
||
else
|
||
gitsigns.nav_hunk('prev')
|
||
end
|
||
end)
|
||
|
||
-- Text object
|
||
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
|
||
end
|
||
|
||
|
||
|
||
}
|
||
},
|
||
{
|
||
"folke/neodev.nvim",
|
||
opts = {
|
||
override = function(_, library)
|
||
library.enabled = true
|
||
library.plugins = true
|
||
end,
|
||
|
||
}
|
||
},
|
||
{
|
||
'nvim-lualine/lualine.nvim',
|
||
opts = {
|
||
sections = {
|
||
lualine_b = {
|
||
},
|
||
lualine_c = {
|
||
{
|
||
'filename',
|
||
path = 3,
|
||
}
|
||
},
|
||
lualine_x = { 'encoding', 'fileformat', 'filetype', 'lsp_status', 'diagnostics', 'branch' },
|
||
}
|
||
},
|
||
dependencies = { 'nvim-tree/nvim-web-devicons' }
|
||
},
|
||
{
|
||
"ellisonleao/gruvbox.nvim",
|
||
priority = 1000,
|
||
config = function()
|
||
vim.cmd.colorscheme "gruvbox"
|
||
end
|
||
},
|
||
{
|
||
"rcarriga/nvim-dap-ui",
|
||
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }
|
||
},
|
||
{
|
||
"folke/trouble.nvim",
|
||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||
opts = {
|
||
},
|
||
},
|
||
{
|
||
"folke/which-key.nvim",
|
||
event = "VeryLazy",
|
||
init = function()
|
||
vim.o.timeout = true
|
||
vim.o.timeoutlen = 300
|
||
end,
|
||
opts = {}
|
||
},
|
||
"dstein64/nvim-scrollview",
|
||
"sindrets/diffview.nvim",
|
||
'nvim-lua/plenary.nvim',
|
||
{
|
||
'nvim-pack/nvim-spectre',
|
||
opts = {
|
||
live_update = true
|
||
}
|
||
},
|
||
{ "cappyzawa/trim.nvim", opts = {} },
|
||
'rhaiscript/vim-rhai'
|
||
})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Treesitter
|
||
-------------------------------------------------------------------------------
|
||
require 'nvim-treesitter.configs'.setup({
|
||
ensure_installed = {},
|
||
auto_install = true,
|
||
highlight = {
|
||
enable = true
|
||
},
|
||
sync_install = false,
|
||
ignore_install = {},
|
||
modules = {}
|
||
})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Autocomplete
|
||
-------------------------------------------------------------------------------
|
||
local cmp = require('cmp')
|
||
cmp.setup({
|
||
snippet = {
|
||
expand = function(args)
|
||
vim.fn["vsnip#anonymous"](args.body)
|
||
end,
|
||
},
|
||
window = {
|
||
},
|
||
mapping = cmp.mapping.preset.insert({
|
||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||
['<C-Space>'] = cmp.mapping.complete(),
|
||
['<C-e>'] = cmp.mapping.abort(),
|
||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||
}),
|
||
sources = cmp.config.sources({
|
||
{ name = 'nvim_lsp' },
|
||
{ name = 'vsnip' },
|
||
}, {
|
||
{ name = 'buffer' },
|
||
})
|
||
})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- LSP
|
||
-------------------------------------------------------------------------------
|
||
local on_attach = function(bufnr)
|
||
local function buf_set_option(...)
|
||
vim.api.nvim_buf_set_option(bufnr, ...)
|
||
end
|
||
|
||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||
|
||
local opts = { buffer = bufnr, noremap = true, silent = true }
|
||
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', 'gr', vim.lsp.buf.references, opts)
|
||
vim.keymap.set('n', '<leader>k', vim.diagnostic.open_float, opts)
|
||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
|
||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
||
end
|
||
vim.api.nvim_create_autocmd("LspAttach", {
|
||
callback = function(args)
|
||
local bufnr = args.buf
|
||
on_attach(bufnr)
|
||
end,
|
||
})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- LSP Sources
|
||
-------------------------------------------------------------------------------
|
||
local null_ls = require("null-ls")
|
||
local sources = {
|
||
null_ls.builtins.formatting.prettier,
|
||
}
|
||
null_ls.setup({ sources = sources })
|
||
vim.lsp.config('luals', {
|
||
on_init = function(client)
|
||
local path = client.workspace_folders[1].name
|
||
if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then
|
||
return
|
||
end
|
||
|
||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||
runtime = {
|
||
version = 'LuaJIT'
|
||
},
|
||
workspace = {
|
||
checkThirdParty = false,
|
||
library = {
|
||
vim.env.VIMRUNTIME
|
||
}
|
||
}
|
||
})
|
||
end,
|
||
settings = {
|
||
Lua = {}
|
||
}
|
||
})
|
||
vim.lsp.config('ruff', {
|
||
on_attach = function(client)
|
||
client.server_capabilities.hoverProvider = false
|
||
end,
|
||
init_options = {
|
||
settings = {
|
||
args = {},
|
||
}
|
||
}
|
||
})
|
||
vim.lsp.enable('lua_ls')
|
||
vim.lsp.enable('ruff')
|
||
vim.lsp.enable('clangd')
|
||
vim.lsp.enable('zls')
|
||
vim.lsp.enable('ruby_lsp')
|
||
vim.lsp.enable('ts_ls')
|
||
vim.lsp.enable('gopls')
|
||
vim.lsp.enable('basedpyright')
|
||
vim.lsp.enable('gdscript')
|
||
vim.lsp.enable('rust_analyzer')
|
||
|
||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||
pattern = { "*.zig" },
|
||
callback = function()
|
||
local orignal = vim.notify
|
||
vim.notify = function(msg, level, opts)
|
||
if msg == 'No code actions available' then
|
||
return
|
||
end
|
||
orignal(msg, level, opts)
|
||
end
|
||
vim.lsp.buf.code_action({
|
||
context = { only = { "source.fixAll" } },
|
||
apply = true,
|
||
})
|
||
end
|
||
})
|
||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||
callback = function()
|
||
vim.lsp.buf.format({
|
||
filter = function(client)
|
||
-- apply whatever logic you want (in this example, we'll only use null-ls)
|
||
return client.name ~= "ts_ls"
|
||
end,
|
||
})
|
||
end,
|
||
})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Debugging
|
||
-------------------------------------------------------------------------------
|
||
local dap = require('dap')
|
||
dap.adapters.gdb = {
|
||
type = "executable",
|
||
command = "gdb",
|
||
args = { "--interpreter=dap", "--eval-command", "set print pretty on" }
|
||
}
|
||
dap.configurations.c = {
|
||
{
|
||
name = "Launch",
|
||
type = "gdb",
|
||
request = "launch",
|
||
program = function()
|
||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||
end,
|
||
args = {}, -- provide arguments if needed
|
||
cwd = "${workspaceFolder}",
|
||
stopAtBeginningOfMainSubprogram = false,
|
||
},
|
||
{
|
||
name = "Select and attach to process",
|
||
type = "gdb",
|
||
request = "attach",
|
||
program = function()
|
||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||
end,
|
||
pid = function()
|
||
local name = vim.fn.input('Executable name (filter): ')
|
||
return require("dap.utils").pick_process({ filter = name })
|
||
end,
|
||
cwd = '${workspaceFolder}'
|
||
},
|
||
{
|
||
name = 'Attach to gdbserver :1234',
|
||
type = 'gdb',
|
||
request = 'attach',
|
||
target = 'localhost:1234',
|
||
program = function()
|
||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||
end,
|
||
cwd = '${workspaceFolder}'
|
||
}
|
||
}
|
||
dap.configurations.cpp = dap.configurations.c
|
||
dap.adapters["rust-gdb"] = {
|
||
type = "executable",
|
||
command = "rust-gdb",
|
||
args = { "--interpreter=dap", "--eval-command", "set print pretty on" }
|
||
}
|
||
function cargo_test_binary()
|
||
local result = vim.system(
|
||
{ "cargo", "test", "--no-run", "--message-format=json" },
|
||
{ text = true }
|
||
):wait()
|
||
|
||
if result.code ~= 0 then
|
||
local result = vim.system(
|
||
{ "cargo", "test", "--no-run" },
|
||
{ text = true }
|
||
):wait()
|
||
vim.notify(
|
||
"Command failed:\n" .. (result.stderr or ""),
|
||
vim.log.levels.ERROR
|
||
)
|
||
end
|
||
|
||
for line in result.stdout:gmatch("[^\r\n]+") do
|
||
local ok, msg = pcall(vim.json.decode, line)
|
||
if ok and msg.executable ~= vim.NIL and msg.executable ~= nil then
|
||
return msg.executable
|
||
end
|
||
end
|
||
|
||
return nil
|
||
end
|
||
|
||
dap.configurations.rust = {
|
||
{
|
||
name = "Debug Test",
|
||
type = "rust-gdb",
|
||
request = "launch",
|
||
program = cargo_test_binary,
|
||
args = {}, -- provide arguments if needed
|
||
cwd = "${workspaceFolder}",
|
||
stopAtBeginningOfMainSubprogram = false,
|
||
},
|
||
{
|
||
name = "Launch",
|
||
type = "rust-gdb",
|
||
request = "launch",
|
||
program = function()
|
||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||
end,
|
||
args = {}, -- provide arguments if needed
|
||
cwd = "${workspaceFolder}",
|
||
stopAtBeginningOfMainSubprogram = false,
|
||
},
|
||
{
|
||
name = "Select and attach to process",
|
||
type = "rust-gdb",
|
||
request = "attach",
|
||
program = function()
|
||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||
end,
|
||
pid = function()
|
||
local name = vim.fn.input('Executable name (filter): ')
|
||
return require("dap.utils").pick_process({ filter = name })
|
||
end,
|
||
cwd = "${workspaceFolder}"
|
||
},
|
||
{
|
||
name = "Attach to gdbserver :1234",
|
||
type = "rust-gdb",
|
||
request = "attach",
|
||
target = "localhost:1234",
|
||
program = function()
|
||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||
end,
|
||
cwd = '${workspaceFolder}'
|
||
}
|
||
}
|
||
require("dapui").setup()
|
||
vim.keymap.set('n', '<leader>dd', require("dapui").toggle, {})
|
||
vim.keymap.set('n', '<leader>db', require("dap").toggle_breakpoint, {})
|
||
vim.fn.sign_define('DapBreakpoint', {
|
||
text = '🛑',
|
||
texthl = 'DapBreakpoint',
|
||
linehl = 'DapBreakpoint',
|
||
numhl =
|
||
'DapBreakpoint'
|
||
})
|
||
vim.fn.sign_define('DapBreakpointCondition',
|
||
{ text = '❓', texthl = 'DapBreakpoint', linehl = 'DapBreakpoint', numhl = 'DapBreakpoint' })
|
||
vim.fn.sign_define('DapBreakpointRejected',
|
||
{ text = '❗', texthl = 'DapBreakpoint', linehl = 'DapBreakpoint', numhl = 'DapBreakpoint' })
|
||
vim.fn.sign_define('DapLogPoint', { text = 'ℹ️', texthl = 'DapLogPoint', linehl = 'DapLogPoint', numhl = 'DapLogPoint' })
|
||
vim.fn.sign_define('DapStopped', { text = '▶️', texthl = 'DapStopped', linehl = 'DapStopped', numhl = 'DapStopped' })
|
||
vim.api.nvim_set_hl(0, 'DapBreakpoint', { ctermbg = 0, fg = '#993939', bg = '#31353f' })
|
||
vim.api.nvim_set_hl(0, 'DapLogPoint', { ctermbg = 0, fg = '#61afef', bg = '#31353f' })
|
||
vim.api.nvim_set_hl(0, 'DapStopped', { ctermbg = 0, fg = '#98c379', bg = '#31353f' })
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Bindings
|
||
-------------------------------------------------------------------------------
|
||
local opts = { noremap = true, silent = true }
|
||
local map = vim.api.nvim_set_keymap
|
||
map('n', '<leader>bdo', "<Cmd>BufferCloseAllButCurrentOrPinned<CR>", opts);
|
||
map('n', '<leader>bp', '<Cmd>BufferPin<CR>', opts)
|
||
map('n', '<A-,>', '<Cmd>BufferPrevious<CR>', opts)
|
||
map('n', '<A-.>', '<Cmd>BufferNext<CR>', opts)
|
||
map('n', '<A-n>', '<Cmd>BufferMovePrevious<CR>', opts)
|
||
map('n', '<A-m>', '<Cmd>BufferMoveNext<CR>', opts)
|
||
map('n', '<A-c>', '<Cmd>BufferClose<CR>', opts)
|
||
map('n', '<A-p>', '<Cmd>BufferPick<CR>', opts)
|
||
map('n', '<A-p>', '<Cmd>BufferPick<CR>', opts)
|
||
map('n', '<A-p>', '<Cmd>BufferPick<CR>', opts)
|
||
local neogit = require('neogit')
|
||
local wk = require("which-key")
|
||
local gitsigns = require('gitsigns')
|
||
wk.add(
|
||
{
|
||
{
|
||
|
||
'<leader>g',
|
||
group = "git",
|
||
mode = "n",
|
||
{
|
||
{
|
||
'<leader>gg',
|
||
function()
|
||
neogit.open({ kind = "split" })
|
||
end,
|
||
desc = "Neogit"
|
||
},
|
||
{ '<leader>gs', gitsigns.stage_hunk, desc = "Stage Hunk" },
|
||
{ '<leader>gr', gitsigns.reset_hunk, desc = "Reset Hunk" },
|
||
{
|
||
'<leader>gS',
|
||
gitsigns.stage_buffer,
|
||
desc = "Stage Buffer"
|
||
},
|
||
{
|
||
'<leader>gR',
|
||
gitsigns.reset_buffer,
|
||
desc = "Reset Buffer"
|
||
},
|
||
{
|
||
'<leader>gp',
|
||
gitsigns.preview_hunk,
|
||
desc = "Preview Hunk"
|
||
},
|
||
{
|
||
'<leader>gb',
|
||
function() gitsigns.blame_line { full = true } end,
|
||
desc = "Blame line"
|
||
},
|
||
{
|
||
'<leader>gy',
|
||
gitsigns.toggle_current_line_blame,
|
||
desc = "Toggle current line blame"
|
||
},
|
||
{
|
||
'<leader>gd',
|
||
gitsigns.diffthis,
|
||
desc = "Diff this"
|
||
},
|
||
{
|
||
'<leader>gD',
|
||
function() gitsigns.diffthis('~') end,
|
||
desc = "Diff this ~"
|
||
},
|
||
{
|
||
'<leader>gt',
|
||
gitsigns.preview_hunk_inline,
|
||
desc = "Toggle deleted"
|
||
},
|
||
},
|
||
{
|
||
'<leader>g',
|
||
group = "vgit",
|
||
mode = "v",
|
||
{
|
||
'<leader>gs',
|
||
function()
|
||
gitsigns.stage_hunk { vim.fn.line('.'),
|
||
vim.fn.line('v') }
|
||
end,
|
||
desc = "Stage Hunk",
|
||
},
|
||
{
|
||
'<leader>gr',
|
||
function()
|
||
gitsigns.reset_hunk { vim.fn.line('.'),
|
||
vim.fn.line('v') }
|
||
end,
|
||
desc = "Reset Hunk",
|
||
},
|
||
}
|
||
} }
|
||
)
|
||
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Eval
|
||
-------------------------------------------------------------------------------
|
||
vim.keymap.set("n", "<leader>mi", ":MoltenInit<CR>",
|
||
{ silent = true, desc = "Initialize the plugin" })
|
||
vim.keymap.set("n", "<leader>e", ":MoltenEvaluateOperator<CR>",
|
||
{ silent = true, desc = "run operator selection" })
|
||
vim.keymap.set("n", "<leader>rl", ":MoltenEvaluateLine<CR>",
|
||
{ silent = true, desc = "evaluate line" })
|
||
vim.keymap.set("n", "<leader>rr", ":MoltenReevaluateCell<CR>",
|
||
{ silent = true, desc = "re-evaluate cell" })
|
||
vim.keymap.set("v", "<leader>r", ":<C-u>MoltenEvaluateVisual<CR>gv",
|
||
{ silent = true, desc = "evaluate visual selection" })
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Telescope
|
||
-------------------------------------------------------------------------------
|
||
local telescope = require('telescope')
|
||
local builtin = require('telescope.builtin')
|
||
vim.keymap.set('n', '<C-p>', builtin.find_files, {})
|
||
vim.keymap.set('n', '<C-A-p>', builtin.commands, {})
|
||
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Search
|
||
-------------------------------------------------------------------------------
|
||
vim.keymap.set('n', '<leader>fg', '<cmd>lua require("spectre").toggle()<CR>', {
|
||
desc = "Toggle Spectre"
|
||
})
|
||
vim.keymap.set('n', '<leader>bf', function()
|
||
print(vim.api.nvim_buf_get_name(0))
|
||
end)
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Godot
|
||
-------------------------------------------------------------------------------
|
||
vim.api.nvim_create_autocmd('BufEnter', {
|
||
pattern = { "*.gd" },
|
||
callback = function()
|
||
vim.api.nvim_buf_set_option(0, "commentstring", "# %s")
|
||
end,
|
||
})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Golang
|
||
-------------------------------------------------------------------------------
|
||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||
pattern = "*.go",
|
||
callback = function()
|
||
local params = vim.lsp.util.make_range_params()
|
||
params.context = { only = { "source.organizeImports" } }
|
||
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params)
|
||
for cid, res in pairs(result or {}) do
|
||
for _, r in pairs(res.result or {}) do
|
||
if r.edit then
|
||
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
|
||
vim.lsp.util.apply_workspace_edit(r.edit, enc)
|
||
end
|
||
end
|
||
end
|
||
vim.lsp.buf.format({ async = false })
|
||
end
|
||
})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Markdown
|
||
-------------------------------------------------------------------------------
|
||
vim.api.nvim_create_autocmd('BufEnter', {
|
||
pattern = { "*.md" },
|
||
callback = function()
|
||
vim.opt.textwidth = 80
|
||
vim.opt_local.formatoptions:append("t")
|
||
end,
|
||
})
|
||
|
||
-------------------------------------------------------------------------------
|
||
-- Comments
|
||
-------------------------------------------------------------------------------
|
||
vim.api.nvim_create_autocmd('BufEnter', {
|
||
callback = function()
|
||
vim.opt.formatoptions:remove("o")
|
||
end,
|
||
})
|