This commit is contained in:
cool-mist
2024-04-06 19:33:03 +05:30
parent 823a4d43ae
commit 840e7c5038
+427 -331
View File
@@ -1,11 +1,11 @@
V = vim V = vim
O = V.opt
OS = package.config:sub(1, 1) == "\\" and "win" or "unix" OS = package.config:sub(1, 1) == "\\" and "win" or "unix"
------------- -------------
-- Options -- -- Options --
------------- -------------
O = V.opt
O.number = true O.number = true
O.relativenumber = false O.relativenumber = false
O.cursorline = true O.cursorline = true
@@ -14,23 +14,25 @@ O.shiftwidth = 2
O.expandtab = true O.expandtab = true
O.preserveindent = true O.preserveindent = true
O.termguicolors = true O.termguicolors = true
O.showmode = false
O.signcolumn = 'yes:1' O.signcolumn = 'yes:1'
O.ignorecase = true O.ignorecase = true
O.smartcase = true O.smartcase = true
O.fillchars = { eob = " " } O.fillchars = { eob = " " }
O.showmode = false
-- Maintain a history of undos so that I can undo even after restart -- Maintain a history of undos so that I can undo even after restart
O.undofile = true O.undofile = true
O.updatetime = 300 O.updatetime = 300
O.timeoutlen = 500 O.timeoutlen = 500
-- Keep atleast 15 lines at the bottom, don't scroll beyond -- Keep atleast 15 lines at the bottom, don't scroll beyond
O.scrolloff = 15 O.scrolloff = 15
O.list = true O.list = true
O.listchars = { tab = '» ', trail = '·', nbsp = '' } O.listchars = { tab = '» ', trail = '·', nbsp = '' }
if OS == "win" then if OS == "win" then
-- The newer pwsh is faster, but this is required for some legacy functionality
-- such as [G]o [T]eams below.
O.shell = "powershell" -- or the newer pwsh O.shell = "powershell" -- or the newer pwsh
O.shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy Bypass -Command" O.shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy Bypass -Command"
O.shellxquote = '' O.shellxquote = ''
@@ -38,58 +40,8 @@ end
O.clipboard = 'unnamedplus' O.clipboard = 'unnamedplus'
O.breakindent = true O.breakindent = true
O.cmdheight = 1 O.cmdheight = 1
O.showmode = false
----------------- O.laststatus = 0
-- Packer conf --
-----------------
V.keymap.set('n', " ", "<Nop>", { silent = true, remap = false })
V.g.mapleader = " "
-- On a fresh install, clone and install packer
local fresh_install_packer = function()
local packerpath = V.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if not V.loop.fs_stat(packerpath) then
V.fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim.git",
packerpath,
})
V.cmd [[packadd packer.nvim]]
return true
end
return false
end
local fresh_install = fresh_install_packer()
----------------------
--- Auto commands ----
----------------------
-- Automatically call PackerCompile when init.lua is saved
V.api.nvim_create_autocmd('BufWritePost', {
desc = 'Auto compile init.lua on config update',
pattern = 'init.lua',
group = V.api.nvim_create_augroup('packer_user_config', { clear = true }),
callback = function()
V.api.nvim_command('source % | PackerCompile')
end
})
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.highlight.on_yank()`
V.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = V.api.nvim_create_augroup('highlight-on-yank', { clear = true }),
callback = function()
V.highlight.on_yank()
end,
})
-------------------- --------------------
----- Leader ------- ----- Leader -------
@@ -98,98 +50,42 @@ V.api.nvim_create_autocmd('TextYankPost', {
V.keymap.set('n', " ", "<Nop>", { silent = true, remap = false }) V.keymap.set('n', " ", "<Nop>", { silent = true, remap = false })
V.g.mapleader = " " V.g.mapleader = " "
-----------------
-- Lazy conf --
-----------------
-- This clones the lazy repo and initilizes the lazy plugin manager
local lazypath = V.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (V.uv or V.loop).fs_stat(lazypath) then
V.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
V.opt.rtp:prepend(lazypath)
--------------- ---------------
--- Plugins --- --- Plugins ---
--------------- ---------------
local packer = require('packer') -- Each plugin is defined below with configuration on how to lazy load it.
-- For help check `:h lazy.nvim-lazy.nvim-plugin-spec` for the list of all
packer.startup({ -- properties
function(u) local lazy = require('lazy')
u 'nvim-lua/plenary.nvim' lazy.setup({
u 'wbthomason/packer.nvim' {
-------------
-- Colorscheme -- Colors --
u { -------------
'catppuccin/nvim', as = 'catppuccin' "catppuccin/nvim",
} name = "catppuccin",
priority = 1000,
-- AI config = function()
u 'github/copilot.vim' require('catppuccin').setup({
-- Dev stuff
u 'williamboman/mason.nvim'
u 'williamboman/mason-lspconfig.nvim'
u 'neovim/nvim-lspconfig'
u 'hrsh7th/nvim-cmp'
u 'hrsh7th/cmp-nvim-lsp'
u 'hrsh7th/cmp-buffer'
u 'hrsh7th/cmp-path'
u 'j-hui/fidget.nvim'
u 'numToStr/Comment.nvim'
u 'mfussenegger/nvim-dap'
u 'nvim-neotest/nvim-nio'
u 'rcarriga/nvim-dap-ui'
u 'Hoffs/omnisharp-extended-lsp.nvim'
u {
"ThePrimeagen/harpoon",
branch = "harpoon2",
requires = { { "nvim-lua/plenary.nvim" } }
}
-- Markdown
u 'godlygeek/tabular'
u 'preservim/vim-markdown'
u 'vim-pandoc/vim-pandoc-syntax'
u 'junegunn/goyo.vim'
-- File tree, telescope
u 'nvim-lua/plenary.nvim'
u 'nvim-tree/nvim-web-devicons'
u 'MunifTanjim/nui.nvim'
u {
'nvim-neo-tree/neo-tree.nvim',
branch = 'v3.x'
}
u {
'nvim-telescope/telescope.nvim',
branch = '0.1.x'
}
-- Others
u 'itchyny/lightline.vim'
u 'folke/which-key.nvim'
if fresh_install then
packer.sync()
end
end,
config = {
max_jobs = 50,
git = {
cmd = 'git',
subcommands = {
update = 'pull --ff-only --progress --rebase=false --force',
install = 'clone --depth %i --no-single-branch --progress',
fetch = 'fetch --depth 1 --progress --force',
checkout = 'checkout %s --',
update_branch = 'merge --ff-only @{u}',
current_branch = 'branch --show-current',
diff = 'log --color=never --pretty=format:FMT --no-show-signature HEAD@{1}...HEAD',
diff_fmt = '%%h %%s (%%cr)',
get_rev = 'rev-parse --short HEAD',
get_msg = 'log --color=never --pretty=format:FMT --no-show-signature HEAD -n 1',
submodules = 'submodule update --init --recursive --progress'
},
}
}
})
-------------------
--- Plugins conf---
-------------------
require('catppuccin').setup({
flavour = "frappe", -- latte, frappe, macchiato, mocha flavour = "frappe", -- latte, frappe, macchiato, mocha
background = { -- :h background background = { -- :h background
light = "frappe", light = "frappe",
@@ -235,11 +131,33 @@ require('catppuccin').setup({
}, },
-- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations)
}, },
}) })
V.cmd([[colorscheme catppuccin-frappe]])
end,
},
{
'nvim-lualine/lualine.nvim',
opts = {
theme = "catppuccin-frappe"
},
},
V.api.nvim_command("colorscheme catppuccin-frappe") -----------------
-- Explorer/UI --
require('neo-tree').setup({ -----------------
-- Neotree shows opens the current directory in a tree view
{
"nvim-neo-tree/neo-tree.nvim",
keys = {
{ "<leader>e", "<cmd>Neotree toggle<cr>", desc = "NeoTree" },
},
dependencies = {
"nvim-tree/nvim-web-devicons",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
},
config = function()
require('neo-tree').setup({
window = { window = {
width = 40, width = 40,
position = 'right', position = 'right',
@@ -250,21 +168,232 @@ require('neo-tree').setup({
hide_dotfiles = false, hide_dotfiles = false,
}, },
}, },
}) })
end,
},
require('telescope').setup() -- Telescope is the fuzzy finder UI. It is used to search files, buffers, recent
-- help tags etc
{
"nvim-telescope/telescope.nvim",
event = { "BufReadPre", "BufNewFile" },
config = true,
version = false,
keys = {
{ '<leader>fb', ':Telescope buffers<cr>', desc = "[F]iles [B]uffers" },
{ '<leader>fo', ':Telescope find_files<cr>', desc = "[F]iles [O]pen" },
{ '<leader>fg', ':Telescope live_grep<cr>', desc = "[F]iles [G]rep" },
{ '<leader>fh', ':Telescope help_tags<cr>', desc = "[F]iles [H]elp tags" },
{ '<leader>fr', ':Telescope oldfiles<cr>', desc = "[F]iles [R]ecent" },
{ '<leader>fn', ':Telescope resume<cr>', desc = "[F]iles [N]ext on the list" },
}
},
-- Nvim-notify will be plugged into the default vim notify system for a
-- better notification box
{
"rcarriga/nvim-notify",
keys = {
{
"<leader>un",
function()
require("notify").dismiss({ silent = true, pending = true })
end,
desc = "Dismiss All Notifications",
},
},
event = "VeryLazy",
config = function()
require('notify').setup({
stages = "static",
timeout = 3000,
max_height = function()
return math.floor(V.o.lines * 0.75)
end,
max_width = function()
return math.floor(V.o.columns * 0.75)
end,
on_open = function(win)
V.api.nvim_win_set_config(win, { zindex = 100 })
end,
})
V.notify = require("notify")
end
},
-- LSP, DAP -- Dressing.nvim will override the vim.input and vim.select dialog boxes
-- so that instead of being shown at the bottom, we are presented with a
-- nice box
{
"stevearc/dressing.nvim",
lazy = true,
init = function()
---@diagnostic disable-next-line: duplicate-set-field
V.ui.select = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return V.ui.select(...)
end
---@diagnostic disable-next-line: duplicate-set-field
V.ui.input = function(...)
require("lazy").load({ plugins = { "dressing.nvim" } })
return V.ui.input(...)
end
end,
},
-- The default borders from nvim-lspconfig, which is what is used to configure the lsp servers -- Harpoon is by far the easiest way to keep track of important files and
-- in this configuration, are not visible. This is a workaround to update the borders key in the -- switch between them while programming.
-- corresponding lsp handlers for hover and signature_help. This is a workaround until I implement {
-- lsp configs per language manually "ThePrimeagen/harpoon",
V.cmd [[autocmd! ColorScheme * highlight NormalFloat guibg=#1f2335]] branch = "harpoon2",
V.cmd [[autocmd! ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335]] dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
harpoon.setup({})
local border = { local opts = { noremap = true, silent = true }
V.keymap.set('n', '<leader>hh', function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, opts)
V.keymap.set('n', '<leader>ha', function() harpoon:list():append() end, opts)
end
},
---------------
-- Dev stuff --
---------------
-- Autocompletion plugin. This plugin is reponsible for showing a dialog box
-- while typing with suggestions. The autocompletion sources have to be separately
-- configured (for example below the LSP source is configured as one of the available
-- sources and so the autocomplete dialog box would list it.
{
"hrsh7th/nvim-cmp",
version = false, -- last release is way too old
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
config = function()
local cmp = require('cmp')
cmp.setup {
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<C-y>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true
}),
},
sources = {
{ name = 'buffer' },
{ name = 'nvim_lsp' },
{ name = 'path' }
},
completion = {
completeopt = 'menu,menuone,noinsert'
}
}
end
},
-- Press g-c to comment a line or a block of text
-- across many languages
{
"numToStr/Comment.nvim",
event = { "BufReadPre", "BufNewFile" },
config = true,
},
-- Used to format markdown tables. And add table of contents to a
-- markdown document. Used only in my markdown files for taking notes
{
"godlygeek/tabular",
keys = {
{ '<leader>tf', ':TableFormat<cr>', desc = "[T]able [F]ormat" },
{ '<leader>tc', ':Toc<cr>', "[T]able of [C]ontents" },
},
},
-- Syntax highlighting for markdown documents. Additionally configures
-- some key bindings and options for markdown files
{
"preservim/vim-markdown",
ft = "markdown.pandoc",
config = function()
V.cmd('let g:vim_markdown_folding_disabled = 1')
V.cmd('let g:vim_markdown_conceal = 0')
V.cmd('let g:tex_conceal = ""')
V.cmd('let g:vim_markdown_math = 1')
V.cmd('let g:vim_markdown_frontmatter = 1')
V.cmd('let g:vim_markdown_toml_frontmatter = 1')
V.cmd('let g:vim_markdown_json_frontmatter = 1')
local opts = { noremap = true, silent = true }
V.api.nvim_set_keymap('n', '<leader>di', ":pu='{'..strftime('%c')..'}'<cr>", opts)
V.api.nvim_set_keymap('n', '<leader>fy', ':let @+=@%<cr>', opts)
V.api.nvim_set_keymap('n', 'gn', 'yi[:e <C-r>*<cr>', opts)
V.api.nvim_set_keymap('n', 'gm', ':e main.md<cr>', opts)
end
},
-- More syntax highlighting for markdown documents. Update the filetype to
-- markdown.pandoc so that the syntax highlighting is applied
{
"vim-pandoc/vim-pandoc-syntax",
ft = "markdown",
config = function()
V.cmd([[
augroup pandoc_syntax
au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup END
]])
V.cmd([[
augroup pandoc_syntax
au! BufNewFile,BufFilePre,BufRead *.markdown set filetype=markdown.pandoc
augroup END
]])
if OS == "win" then
-- [G]o [T]eams to copy contents to clipboard so that I can copy paste my
-- markdown to teams
local opts = { noremap = true, silent = true }
V.api.nvim_set_keymap('n', 'gt', ':!pandoc -f markdown-smart -t html % | Set-Clipboard -AsHtml<cr><cr>', opts)
end
end
},
-- Copilot!!
{
"github/copilot.vim",
event = { "BufReadPre", "BufNewFile" },
},
-- lspconfig is the configuration framework for the nvim lsp client. It has best effort
-- configs for every language. Mason.nvim is the plugin that will install the lsp servers
-- (and dap servers). Mason-lspconfig is the plugin that will configure the lsp servers
-- that needs to be installed and available. Otherwise, we can still use the :Mason command
-- to install the required lsp and dap servers
{
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
config = function()
require('lspconfig').lua_ls.setup({})
require("lspconfig").powershell_es.setup({})
-- The default borders from nvim-lspconfig, which is what is used to configure the lsp servers
-- in this configuration, are not visible. This is a workaround to update the borders key in the
-- corresponding lsp handlers for hover and signature_help. This is a workaround until I implement
-- lsp configs per language manually
V.cmd [[autocmd! ColorScheme * highlight NormalFloat guibg=#1f2335]]
V.cmd [[autocmd! ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335]]
local border = {
{ "🭽", "FloatBorder" }, { "🭽", "FloatBorder" },
{ "", "FloatBorder" }, { "", "FloatBorder" },
{ "🭾", "FloatBorder" }, { "🭾", "FloatBorder" },
@@ -273,31 +402,26 @@ local border = {
{ "", "FloatBorder" }, { "", "FloatBorder" },
{ "🭼", "FloatBorder" }, { "🭼", "FloatBorder" },
{ "", "FloatBorder" }, { "", "FloatBorder" },
} }
require("mason").setup() -- RUST --
require("mason-lspconfig").setup() local handlers = {
local dap = require('dap')
local dapui = require('dapui')
-- Rust
local handlers = {
["textDocument/hover"] = V.lsp.with(V.lsp.handlers.hover, { border = border }), ["textDocument/hover"] = V.lsp.with(V.lsp.handlers.hover, { border = border }),
["textDocument/signatureHelp"] = V.lsp.with(V.lsp.handlers.signature_help, { border = border }), ["textDocument/signatureHelp"] = V.lsp.with(V.lsp.handlers.signature_help, { border = border }),
} }
require("lspconfig").rust_analyzer.setup { handlers = handlers } require("lspconfig").rust_analyzer.setup { handlers = handlers }
-- C# -- C# --
local omnisharp_extended = require("omnisharp_extended") -- decompilation support local omnisharp_extended = require("omnisharp_extended") -- decompilation support
local omnisharp_handlers = { local omnisharp_handlers = {
["textDocument/hover"] = V.lsp.with(V.lsp.handlers.hover, { border = border }), ["textDocument/hover"] = V.lsp.with(V.lsp.handlers.hover, { border = border }),
["textDocument/signatureHelp"] = V.lsp.with(V.lsp.handlers.signature_help, { border = border }), ["textDocument/signatureHelp"] = V.lsp.with(V.lsp.handlers.signature_help, { border = border }),
["textDocument/definition"] = omnisharp_extended.definition_handler, ["textDocument/definition"] = omnisharp_extended.definition_handler,
["textDocument/references"] = omnisharp_extended.references_handler, ["textDocument/references"] = omnisharp_extended.references_handler,
["textDocument/implementation"] = omnisharp_extended.implementation_handler, ["textDocument/implementation"] = omnisharp_extended.implementation_handler,
} }
require("lspconfig").omnisharp.setup { require("lspconfig").omnisharp.setup {
handlers = omnisharp_handlers, handlers = omnisharp_handlers,
enable_editorconfig_support = true, enable_editorconfig_support = true,
enable_ms_build_load_projects_on_demand = false, enable_ms_build_load_projects_on_demand = false,
@@ -306,39 +430,10 @@ require("lspconfig").omnisharp.setup {
enable_import_completion = false, enable_import_completion = false,
sdk_include_prereleases = true, sdk_include_prereleases = true,
analyze_open_documents_only = true, analyze_open_documents_only = true,
}
dap.adapters.netcoredbg = {
type = 'executable',
command = V.fn.stdpath("data") .. '/mason/packages/netcoredbg/netcoredbg/netcoredbg',
args = { '--interpreter=vscode' },
options = {
detached = false, -- Will put the output in the REPL. #CloseEnough
} }
}
dap.configurations.cs = { -- Add default LSP keybindings
{ V.api.nvim_create_autocmd('LspAttach', {
type = "netcoredbg",
name = "launch - netcoredbg",
request = "launch",
program = function()
return V.fn.input('DLL: ', V.fn.getcwd() .. '/bin/Debug/net8.0/', 'file')
end,
cwd = "${workspaceFolder}",
console = "integratedTerminal"
},
}
-- Lua
require("lspconfig").lua_ls.setup {}
-- Powershell
require("lspconfig").powershell_es.setup {}
-- General LSP keybindings
V.api.nvim_create_autocmd('LspAttach', {
group = V.api.nvim_create_augroup('UserLspConfig', {}), group = V.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev) callback = function(ev)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
@@ -351,34 +446,63 @@ V.api.nvim_create_autocmd('LspAttach', {
V.keymap.set('n', 'gd', V.lsp.buf.definition, opts) V.keymap.set('n', 'gd', V.lsp.buf.definition, opts)
V.keymap.set('n', 'K', V.lsp.buf.hover, opts) V.keymap.set('n', 'K', V.lsp.buf.hover, opts)
V.keymap.set('n', 'gi', V.lsp.buf.implementation, opts) V.keymap.set('n', 'gi', V.lsp.buf.implementation, opts)
-- V.keymap.set('n', '<space>k', V.lsp.buf.signature_help, opts) V.keymap.set('n', '<leader>k', V.lsp.buf.signature_help, opts)
-- V.keymap.set('n', '<space>wa', V.lsp.buf.add_workspace_folder, opts) V.keymap.set('n', '<leader>wa', V.lsp.buf.add_workspace_folder, opts)
-- V.keymap.set('n', '<space>wr', V.lsp.buf.remove_workspace_folder, opts) V.keymap.set('n', '<leader>wr', V.lsp.buf.remove_workspace_folder, opts)
-- V.keymap.set('n', '<space>wl', function() V.keymap.set('n', '<leader>wl', function()
-- print(V.inspect(V.lsp.buf.list_workspace_folders())) print(V.inspect(V.lsp.buf.list_workspace_folders()))
-- end, opts) end, opts)
V.keymap.set('n', '<space>D', V.lsp.buf.type_definition, opts) V.keymap.set('n', '<leader>D', V.lsp.buf.type_definition, opts)
V.keymap.set('n', '<space>rn', V.lsp.buf.rename, opts) V.keymap.set('n', '<leader>rn', V.lsp.buf.rename, opts)
V.keymap.set({ 'n', 'v' }, '<space>ca', V.lsp.buf.code_action, opts) V.keymap.set({ 'n', 'v' }, '<leader>ca', V.lsp.buf.code_action, opts)
V.keymap.set('n', 'gr', V.lsp.buf.references, opts) V.keymap.set('n', 'gr', V.lsp.buf.references, opts)
V.keymap.set('n', '<space>ff', function() V.keymap.set('n', '<leader>ff', function()
V.lsp.buf.format { async = true } V.lsp.buf.format { async = true }
end, opts) end, opts)
V.keymap.set('n', '[d', V.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
V.keymap.set('n', ']d', V.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
V.keymap.set('n', '<leader>fe', V.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
V.keymap.set('n', '<leader>fd', V.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
V.keymap.set('n', '<leader>fe', V.diagnostic.open_float, { desc = 'Open diagnostic message on the line' })
end, end,
}) })
end,
dependencies = {
-- This plugin provides decompilation support for the omnisharp LSP
"Hoffs/omnisharp-extended-lsp.nvim",
{
-- This plugin provides a way to configure which LSP servers to install
"williamboman/mason-lspconfig.nvim",
config = function()
require('mason-lspconfig').setup {
ensure_installed = {
"lua_ls",
"powershell_es",
"rust_analyzer",
"omnisharp",
-- "netcoredbg", Install this manually, this is DAP, not LSP
}
}
end,
dependencies = {
-- This plugin provides a way to install LSP and DAP servers
{ "williamboman/mason.nvim", config = true }
},
},
}
},
-- General DAP settings -- This is the DAP client for nvim. Mason (from the previous configuration) still is
-- responsible for installing the DAP servers. Nvim-Dap is used to configure the different
V.keymap.set('n', '<F5>', function() require('dap').continue() end) -- debug adapters properly
V.keymap.set('n', '<F10>', function() require('dap').step_over() end) {
V.keymap.set('n', '<F11>', function() require('dap').step_into() end) "mfussenegger/nvim-dap",
V.keymap.set('n', '<F12>', function() require('dap').step_out() end) dependencies = {
V.keymap.set('n', '<Leader>b', function() require('dap').toggle_breakpoint() end) -- This is the UI component of the DAP. It shows the stack, watches, breakpoints, repl etc.
V.keymap.set('n', '<Leader>B', function() require('dap').set_breakpoint() end) "rcarriga/nvim-dap-ui",
V.keymap.set('n', '<Leader>dr', function() require('dap').repl.open() end) config = function()
V.keymap.set('n', '<Leader>dl', function() require('dap').run_last() end) local dapui = require('dapui')
dapui.setup({
dapui.setup({
icons = { expanded = "", collapsed = "", current_frame = "" }, icons = { expanded = "", collapsed = "", current_frame = "" },
mappings = { mappings = {
-- Use a table to apply multiple mappings -- Use a table to apply multiple mappings
@@ -457,95 +581,87 @@ dapui.setup({
max_type_length = nil, -- Can be integer or nil. max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil. max_value_lines = 100, -- Can be integer or nil.
} }
}) })
end,
dependencies = {
dap.listeners.after.event_initialized["dapui_config"] = function() -- TODO
dapui.open() "nvim-neotest/nvim-nio",
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
local cmp = require('cmp')
cmp.setup {
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<C-y>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true
}),
},
sources = {
{ name = 'buffer' },
{ name = 'nvim_lsp' },
{ name = 'path' }
},
completion = {
completeopt = 'menu,menuone,noinsert'
} }
} },
config = function()
local dap = require('dap')
require('Comment').setup(); -- Netcoredbg is a debug adapter for C# and .NET applications. It needs to be manually
-- installed at the moment through :Mason and selecting the netcoredbg DAP. The below
-- configuration tells how to start the netcoredbg process during the debugging process.
dap.adapters.netcoredbg = {
type = 'executable',
command = V.fn.stdpath("data") .. '/mason/packages/netcoredbg/netcoredbg/netcoredbg',
args = { '--interpreter=vscode' },
options = {
detached = false, -- Will put the output in the REPL. #CloseEnough
}
}
local whichkey = require('which-key') -- Below configuration tells how to launch a debugging interactive session for a C#
whichkey.setup() -- application when using the netcoredbg adapeter.
dap.configurations.cs = {
{
type = "netcoredbg",
name = "launch - netcoredbg",
request = "launch",
program = function()
return V.fn.input('DLL: ', V.fn.getcwd() .. '/bin/Debug/net8.0/', 'file')
end,
cwd = "${workspaceFolder}",
console = "integratedTerminal"
},
}
local harpoon = require('harpoon') -- No idea what the below does, but it is required for the dap to work
harpoon.setup() local dapui = require('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
end,
keys = {
{ '<F5>', '<cmd>lua require("dap").continue()<cr>', desc = "Continue" },
{ '<F10>', '<cmd>lua require("dap").step_over()<cr>', desc = "Step Over" },
{ '<F11>', '<cmd>lua require("dap").step_into()<cr>', desc = "Step Into" },
{ '<F12>', '<cmd>lua require("dap").step_out()<cr>', desc = "Step Out" },
{ '<leader>b', '<cmd>lua require("dap").toggle_breakpoint()<cr>', desc = "Toggle Breakpoint" },
{ '<leader>B', '<cmd>lua require("dap").set_breakpoint()<cr>', desc = "Set Breakpoint" },
{ '<leader>dr', '<cmd>lua require("dap").repl.open()<cr>', desc = "Open REPL" },
{ '<leader>dl', '<cmd>lua require("dap").run_last()<cr>', desc = "Run Last" },
}
-- vim-markdown },
V.cmd('let g:vim_markdown_folding_disabled = 1')
V.cmd('let g:vim_markdown_conceal = 0')
V.cmd('let g:tex_conceal = ""')
V.cmd('let g:vim_markdown_math = 1')
V.cmd('let g:vim_markdown_frontmatter = 1')
V.cmd('let g:vim_markdown_toml_frontmatter = 1')
V.cmd('let g:vim_markdown_json_frontmatter = 1')
V.cmd([[ -- Shows a popups with the keybindings that are available after a small delay
augroup pandoc_syntax {
au! BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc "folke/which-key.nvim",
augroup END config = true
]]) },
})
V.cmd([[
augroup pandoc_syntax
au! BufNewFile,BufFilePre,BufRead *.markdown set filetype=markdown.pandoc
augroup END
]])
--------------- ---------------
-- Key binds -- -- Key binds --
--------------- ---------------
-- Some misc keybindings that are not part of any plugin
local keymap = V.api.nvim_set_keymap local keymap = V.api.nvim_set_keymap
local luakeymap = V.keymap.set
local opts = { noremap = true, silent = true } local opts = { noremap = true, silent = true }
keymap('n', '<leader>w', ':w<cr>', opts) keymap('n', '<leader>w', ':w<cr>', opts)
keymap('n', '<leader>q', ':q<cr>', opts) keymap('n', '<leader>q', ':q<cr>', opts)
keymap('n', '<leader>Q', ':qa!<cr>', opts) keymap('n', '<leader>Q', ':qa!<cr>', opts)
-- Neotree
keymap('n', '<leader>e', ':Neotree reveal toggle<cr>', opts)
-- Telescope
keymap('n', '<leader>fb', ':Telescope buffers<cr>', opts)
keymap('n', '<leader>fo', ':Telescope find_files<cr>', opts)
keymap('n', '<leader>fg', ':Telescope live_grep<cr>', opts)
keymap('n', '<leader>fh', ':Telescope help_tags<cr>', opts)
keymap('n', '<leader>fr', ':Telescope oldfiles<cr>', opts)
keymap('n', '<leader>fn', ':Telescope resume<cr>', opts)
-- Navidate windows -- Navidate windows
keymap("n", "<C-h>", "<C-w>h", opts) keymap("n", "<C-h>", "<C-w>h", opts)
keymap("n", "<C-j>", "<C-w>j", opts) keymap("n", "<C-j>", "<C-w>j", opts)
@@ -562,41 +678,21 @@ keymap("x", "K", ":move '<-2<cr>gv-gv", opts)
keymap("x", "<A-j>", ":move '>+1<cr>gv-gv", opts) keymap("x", "<A-j>", ":move '>+1<cr>gv-gv", opts)
keymap("x", "<A-k>", ":move '<-2<cr>gv-gv", opts) keymap("x", "<A-k>", ":move '<-2<cr>gv-gv", opts)
-- Diagnostics
keymap('n', '<space>fe', ":lua vim.diagnostic.open_float()<cr>", opts)
-- terminal
keymap("t", "<Esc>", "<C-\\><C-n>", opts)
keymap("n", "tt", ":ToggleTerm<cr>", opts)
keymap("x", "tt", ":ToggleTerm<cr>", opts)
-- Notes
keymap('n', '<leader>tf', ':TableFormat<cr>', opts)
keymap('n', '<leader>tc', ':Toc<cr>', opts)
keymap('n', '<leader>di', ":pu='{'..strftime('%c')..'}'<cr>", opts)
keymap('n', '<leader>o', 'o<esc>i', opts)
keymap('n', '<leader>fy', ':let @+=@%<cr>', opts)
keymap('n', 'gn', 'yi[:e <C-r>*<cr>', opts)
keymap('n', 'gm', ':e main.md<cr>', opts)
if OS == "win" then
-- [G]o [T]eams to copy contents to clipboard so that I can copy paste my
-- markdown to teams
keymap('n', 'gt', ':!pandoc -f markdown-smart -t html % | Set-Clipboard -AsHtml<cr><cr>', opts)
end
-- Present
keymap('n', '<leader>g', ':Goyo<cr>', opts)
-- Diagnostics
luakeymap('n', '[d', V.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
luakeymap('n', ']d', V.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
luakeymap('n', '<leader>fe', V.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
luakeymap('n', '<leader>fd', V.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
-- Misc -- Misc
keymap('n', '<S-u>', ':red<cr>', opts) keymap('n', '<S-u>', ':red<cr>', opts)
keymap('n', '<ESC>', '<cmd>nohlsearch<cr>', {}) keymap('n', '<ESC>', '<cmd>nohlsearch<cr>', {})
-- Harpoon ----------
luakeymap('n', '<leader>hh', function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, opts) -- Misc --
luakeymap('n', '<leader>ha', function() harpoon:list():append() end, opts) ----------
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.highlight.on_yank()`
V.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = V.api.nvim_create_augroup('highlight-on-yank', { clear = true }),
callback = function()
V.highlight.on_yank()
end,
})