Compare commits
87 Commits
a6fc668de5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| f59a288d59 | |||
| 5def28d407 | |||
| 2dec8af915 | |||
| 27c50224f7 | |||
| 39967dc120 | |||
| bea244a4aa | |||
| f08562558b | |||
| bc5ddb6dc7 | |||
| f213c20d23 | |||
| 481c127583 | |||
| e0286197f8 | |||
| 6fefe27f0e | |||
| 82143dea23 | |||
| 144d2b11cf | |||
| 44199d81b4 | |||
| 6401649361 | |||
| ee385eb5da | |||
| 95d8c16621 | |||
| 25209c7928 | |||
| 555644bc02 | |||
| f51bbe1236 | |||
| b65d0ef36d | |||
| 65c394a681 | |||
| 4a03e07c59 | |||
| 3a8fb33ced | |||
| 3d736dca8a | |||
| 745f6c408b | |||
| 62f3061f48 | |||
| 8653c8b4cd | |||
| d261a49feb | |||
| 53ad787167 | |||
| 595c45724d | |||
| 4fc07f90d4 | |||
| 53d9b50e0b | |||
| 4f38790589 | |||
| 00f87db692 | |||
| 5a265839f9 | |||
| 0e2dcbc55b | |||
| 7ff5ca4a6a | |||
| 1529032ffb | |||
| 3b79830ece | |||
| fad688fc15 | |||
| 0471dd67c4 | |||
| 94288ce806 | |||
| 516d3cbce7 | |||
| a8c313b9cd | |||
|
|
709b5b775f | ||
| d588b435ea | |||
| fa06857e83 | |||
| 440fea18ee | |||
| d0b4e419e6 | |||
| 1704b2f482 | |||
| dc6aa82d73 | |||
| 0b6fa260b9 | |||
| bc201b3581 | |||
| fee0736439 | |||
| 09534cf74c | |||
| 0f740ad8c0 | |||
| 18d5f5896b | |||
|
|
946d1e7b4a | ||
| 14709a12a7 | |||
| 830ace507e | |||
| 96e912181c | |||
| 7536173150 | |||
| d0315cc1ee | |||
| de0e52f0db | |||
| e929956a8c | |||
| c895484b75 | |||
| 2814270762 | |||
| dc78a25253 | |||
| a13d97f3ff | |||
| 33f3e8e920 | |||
| cd5cd3ba69 | |||
| 7963c56fd9 | |||
| 55f5da7db7 | |||
| 0434fc3ac2 | |||
|
|
2cd7d34375 | ||
| d1f83a05b9 | |||
| 8b4258408e | |||
| 8a5f4a3063 | |||
|
|
aa7da3dfe2 | ||
| 68e8635ae1 | |||
|
|
6217dd7f54 | ||
| 2bae0d50d6 | |||
| 59d3ea0978 | |||
| 0410dfc23d | |||
| 0d1983e8bb |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
lazy-lock.json
|
lazy-lock.json
|
||||||
spell/*.spl
|
spell/*.spl
|
||||||
|
lua/local.lua
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
local opts = { buffer = true, remap = false, silent = true }
|
local opts = { buffer = true, remap = false, silent = true }
|
||||||
vim.keymap.set('n', '0', ':PreProcIfWrap<CR>', opts)
|
|
||||||
vim.keymap.set('v', '0', ':PreProcIfWrap<CR>', opts)
|
vim.keymap.set('v', '0', ':PreProcIfWrap<CR>', opts)
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ vim.opt.commentstring = '//%s'
|
|||||||
vim.opt.matchpairs:append('<:>')
|
vim.opt.matchpairs:append('<:>')
|
||||||
|
|
||||||
local opts = { buffer = true, remap = false, silent = true }
|
local opts = { buffer = true, remap = false, silent = true }
|
||||||
vim.keymap.set('n', '0', ':PreProcIfWrap<CR>', opts)
|
-- vim.keymap.set('n', '0', ':PreProcIfWrap<CR>', opts)
|
||||||
vim.keymap.set('v', '0', ':PreProcIfWrap<CR>', opts)
|
vim.keymap.set('v', '0', ':PreProcIfWrap<CR>', opts)
|
||||||
|
|||||||
1
after/ftplugin/dap-view-term.lua
Normal file
1
after/ftplugin/dap-view-term.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vim.o.signcolumn = 'no'
|
||||||
6
after/ftplugin/gomod.lua
Normal file
6
after/ftplugin/gomod.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
vim.opt.expandtab = false
|
||||||
|
vim.opt.tabstop = 4
|
||||||
|
vim.opt.shiftwidth = 4
|
||||||
|
vim.opt.softtabstop = 4
|
||||||
|
vim.wo.listchars = 'extends:»,nbsp:⦸,precedes:«,tab: ,trail:·'
|
||||||
|
vim.bo.formatprg = 'gofmt'
|
||||||
2
after/indent/python.lua
Normal file
2
after/indent/python.lua
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- Use treesitter for Python indenting since regex indenting is broken
|
||||||
|
vim.opt.indentexpr = 'nvim_treesitter#indent()'
|
||||||
9
init.lua
9
init.lua
@@ -1,6 +1,15 @@
|
|||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
|
if vim.g.neovide then
|
||||||
|
vim.o.guifont = "CaskaydiaCove Nerd Font:h12"
|
||||||
|
vim.g.neovide_cursor_animation_length = 0
|
||||||
|
vim.g.neovide_show_border = true -- macOS only
|
||||||
|
end
|
||||||
|
|
||||||
|
-- load config from lua/local.lua if present
|
||||||
|
pcall(function() require('local') end)
|
||||||
|
|
||||||
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
vim.fn.system({ 'git', 'clone', '--filter=blob:none',
|
vim.fn.system({ 'git', 'clone', '--filter=blob:none',
|
||||||
|
|||||||
@@ -31,8 +31,18 @@ local kanagawa = {
|
|||||||
|
|
||||||
vim.cmd.highlight('WinSeparator', 'guifg=' .. dragon.ui.bg_m3, 'guibg=' .. dragon.ui.bg_m3)
|
vim.cmd.highlight('WinSeparator', 'guifg=' .. dragon.ui.bg_m3, 'guibg=' .. dragon.ui.bg_m3)
|
||||||
vim.cmd.highlight('MsgSeparator', 'guifg=' .. dragon.ui.bg_m3, 'guibg=' .. dragon.ui.bg_m3)
|
vim.cmd.highlight('MsgSeparator', 'guifg=' .. dragon.ui.bg_m3, 'guibg=' .. dragon.ui.bg_m3)
|
||||||
vim.cmd.highligh('TreesitterContext', 'guibg=' .. dragon.ui.bg_gutter)
|
vim.cmd.highlight('TreesitterContext', 'guibg=' .. dragon.ui.bg_gutter)
|
||||||
vim.cmd.highlight('link zshTodo Comment')
|
|
||||||
|
-- Don't lighlight TODO specially in comments
|
||||||
|
for _, todo_group in pairs({
|
||||||
|
'confTodo',
|
||||||
|
'mojoTodo',
|
||||||
|
'ps1CommentTodo',
|
||||||
|
'pythonTodo',
|
||||||
|
'zshTodo',
|
||||||
|
}) do
|
||||||
|
vim.cmd.highlight('link ' .. todo_group .. ' Comment')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
return {
|
|
||||||
-- TODO: v0.10.0 Added built-in |commenting| support.
|
|
||||||
'terrortylor/nvim-comment',
|
|
||||||
config = function()
|
|
||||||
require('nvim_comment').setup({
|
|
||||||
-- should comment out empty or whitespace only lines
|
|
||||||
comment_empty = false,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
}
|
|
||||||
@@ -1,42 +1,3 @@
|
|||||||
-- Language servers
|
|
||||||
local ensure_installed = {
|
|
||||||
'clangd', -- C/C++
|
|
||||||
'lua_ls', -- Lua
|
|
||||||
'opencl_ls', -- OpenCL
|
|
||||||
}
|
|
||||||
|
|
||||||
if vim.fn.executable('npm') == 1 then
|
|
||||||
local ensure_install_from_npm = {
|
|
||||||
'ansiblels', -- Ansible
|
|
||||||
'bashls', -- Bash
|
|
||||||
'docker_compose_language_service', -- Docker Compose
|
|
||||||
'dockerls', -- Dockerfile
|
|
||||||
'html', -- HTML
|
|
||||||
'jsonls', -- JSON
|
|
||||||
'pyright', -- Python
|
|
||||||
'vimls', -- VimScript
|
|
||||||
'yamlls', -- YAML
|
|
||||||
}
|
|
||||||
for _, package in ipairs(ensure_install_from_npm) do
|
|
||||||
table.insert(ensure_installed, package)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.executable('pip') == 1 then
|
|
||||||
local ensure_install_from_pip = {
|
|
||||||
'cmake', -- CMake
|
|
||||||
'esbonio', -- Sphinx
|
|
||||||
'ruff_lsp', -- Python
|
|
||||||
}
|
|
||||||
for _, package in ipairs(ensure_install_from_pip) do
|
|
||||||
table.insert(ensure_installed, package)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.has('win32') == 1 then
|
|
||||||
table.insert(ensure_installed, 'powershell_es')
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
@@ -50,11 +11,11 @@ return {
|
|||||||
'saadparwaiz1/cmp_luasnip', -- Source for LuaSnip snippets
|
'saadparwaiz1/cmp_luasnip', -- Source for LuaSnip snippets
|
||||||
'hrsh7th/cmp-buffer', -- Source for buffer words
|
'hrsh7th/cmp-buffer', -- Source for buffer words
|
||||||
'hrsh7th/cmp-path', -- Source for filesystem paths
|
'hrsh7th/cmp-path', -- Source for filesystem paths
|
||||||
'kbenzie/cmp-git', -- Source for Git/GitHub/GitLab
|
'petertriho/cmp-git', -- Source for Git/GitHub/GitLab
|
||||||
'hrsh7th/nvim-cmp', -- Completion engine combines and uses the above
|
'hrsh7th/nvim-cmp', -- Completion engine combines and uses the above
|
||||||
|
|
||||||
-- Lua vim module support in lua language server
|
-- Lua vim module support in lua language server
|
||||||
'folke/neodev.nvim',
|
{ 'folke/lazydev.nvim', ft = 'lua', opts = {} },
|
||||||
-- Expose clangd extensions
|
-- Expose clangd extensions
|
||||||
'p00f/clangd_extensions.nvim',
|
'p00f/clangd_extensions.nvim',
|
||||||
|
|
||||||
@@ -72,14 +33,11 @@ return {
|
|||||||
},
|
},
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
local lspconfig_default_opts = {
|
local capabilities = vim.tbl_deep_extend(
|
||||||
-- Broadcast full client capabilities to language servers
|
'force', vim.lsp.protocol.make_client_capabilities(),
|
||||||
capabilities = vim.tbl_deep_extend(
|
require('cmp_nvim_lsp').default_capabilities())
|
||||||
'force', vim.lsp.protocol.make_client_capabilities(),
|
|
||||||
require('cmp_nvim_lsp').default_capabilities()),
|
|
||||||
}
|
|
||||||
|
|
||||||
local lspconfig_custom_opts = {
|
local server_opts = {
|
||||||
clangd = {
|
clangd = {
|
||||||
cmd = { 'clangd', '--completion-style=detailed' },
|
cmd = { 'clangd', '--completion-style=detailed' },
|
||||||
},
|
},
|
||||||
@@ -91,6 +49,12 @@ return {
|
|||||||
disable = { 'missing-fields', },
|
disable = { 'missing-fields', },
|
||||||
globals = { 'vim', },
|
globals = { 'vim', },
|
||||||
},
|
},
|
||||||
|
workspace = {
|
||||||
|
library = {
|
||||||
|
vim.fn.expand('~/.hammerspoon/Spoons'),
|
||||||
|
vim.fn.expand('~/.hammerspoon/Spoons/EmmyLua.spoon/annotations/'),
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -102,19 +66,84 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
harper_ls = {
|
||||||
|
filetypes = {}, -- Disable for all filetypes
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for server, opts in pairs(server_opts) do
|
||||||
|
-- Broadcast full client capabilities to language servers
|
||||||
|
opts.capabilities = vim.tbl_deep_extend(
|
||||||
|
'force', {}, capabilities, opts.capabilities or {})
|
||||||
|
vim.lsp.config(server, opts)
|
||||||
|
end
|
||||||
|
|
||||||
require('mason').setup()
|
require('mason').setup()
|
||||||
|
|
||||||
|
local language_servers = {
|
||||||
|
'clangd', -- C/C++
|
||||||
|
'lua_ls', -- Lua
|
||||||
|
'opencl_ls', -- OpenCL
|
||||||
|
'harper_ls', -- Spelling & grammar
|
||||||
|
'marksman', -- Markdown
|
||||||
|
'tinymist', -- Typst
|
||||||
|
}
|
||||||
|
|
||||||
|
if vim.fn.executable('npm') == 1 then
|
||||||
|
for _, package in ipairs({
|
||||||
|
'ansiblels', -- Ansible
|
||||||
|
'bashls', -- Bash
|
||||||
|
'docker_compose_language_service', -- Docker Compose
|
||||||
|
'dockerls', -- Dockerfile
|
||||||
|
'html', -- HTML
|
||||||
|
'jsonls', -- JSON
|
||||||
|
'pyright', -- Python
|
||||||
|
'vimls', -- VimScript
|
||||||
|
'yamlls', -- YAML
|
||||||
|
}) do table.insert(language_servers, package) end
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.executable('pip') == 1 then
|
||||||
|
for _, package in ipairs({
|
||||||
|
'cmake', -- CMake
|
||||||
|
'esbonio', -- Sphinx
|
||||||
|
'ruff', -- Python
|
||||||
|
}) do table.insert(language_servers, package) end
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.executable('go') == 1 then
|
||||||
|
table.insert(language_servers, 'gopls') -- Go
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.has('win32') == 1 then
|
||||||
|
table.insert(language_servers, 'powershell_es') -- PowerShell
|
||||||
|
end
|
||||||
|
|
||||||
require('mason-lspconfig').setup({
|
require('mason-lspconfig').setup({
|
||||||
automatic_installation = false,
|
ensure_installed = language_servers,
|
||||||
ensure_installed = ensure_installed,
|
})
|
||||||
handlers = {
|
|
||||||
function(server_name)
|
-- (Dis|en)able harper-ls when spell mode is (dis|en)enabled.
|
||||||
local opts = vim.tbl_deep_extend("force",
|
vim.api.nvim_create_autocmd("OptionSet", {
|
||||||
lspconfig_default_opts, lspconfig_custom_opts[server_name] or {})
|
pattern = "spell",
|
||||||
require('lspconfig')[server_name].setup(opts)
|
callback = function()
|
||||||
end,
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
},
|
if vim.v.option_new then
|
||||||
|
vim.lsp.start({
|
||||||
|
name = "harper_ls",
|
||||||
|
cmd = { "harper-ls", "--stdio" },
|
||||||
|
root_dir = vim.fn.getcwd(),
|
||||||
|
}, { bufnr = bufnr })
|
||||||
|
else
|
||||||
|
for _, client in pairs(vim.lsp.get_clients({ bufnr = bufnr })) do
|
||||||
|
if client.name == "harper_ls" then
|
||||||
|
vim.lsp.buf_detach_client(bufnr, client.id)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
@@ -138,15 +167,15 @@ return {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
{ name = 'path' },
|
{ name = 'path' },
|
||||||
{ name = 'git' },
|
{ name = 'git' },
|
||||||
},
|
},
|
||||||
|
|
||||||
formatting = {
|
formatting = {
|
||||||
format = function(entry, vim_item)
|
format = function(_, vim_item)
|
||||||
-- Set a limit to how wide the completion menu can be
|
-- Set a limit to how wide the completion menu can be
|
||||||
local winwidth = vim.fn.winwidth(vim.api.nvim_get_current_win())
|
local winwidth = vim.fn.winwidth(vim.api.nvim_get_current_win())
|
||||||
local menuwidth = math.min(winwidth / 2, 70)
|
local menuwidth = math.min(winwidth / 2, 70)
|
||||||
@@ -164,8 +193,7 @@ return {
|
|||||||
documentation = cmp.config.window.bordered(),
|
documentation = cmp.config.window.bordered(),
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Don't preselect any completion items, fixes wird behaviour in gopls
|
preselect = 'None', -- Don't preselect completions suggested by source
|
||||||
preselect = cmp.PreselectMode.None,
|
|
||||||
})
|
})
|
||||||
require("cmp_git").setup({})
|
require("cmp_git").setup({})
|
||||||
|
|
||||||
@@ -196,16 +224,10 @@ return {
|
|||||||
-- Refactoring mappings
|
-- Refactoring mappings
|
||||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||||
|
|
||||||
-- Help mappings
|
|
||||||
-- TODO: v0.10.0 |vim.lsp.start()| now maps |K| to use
|
|
||||||
-- |vim.lsp.buf.hover()| if the server supports it, unless
|
|
||||||
-- |'keywordprg'| was customized before calling |vim.lsp.start()|.
|
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
|
||||||
|
|
||||||
-- Format whole buffer mapping
|
-- Format whole buffer mapping
|
||||||
vim.keymap.set('n', '<leader>gq', vim.lsp.buf.format, opts)
|
vim.keymap.set('n', '<leader>gq', vim.lsp.buf.format, opts)
|
||||||
|
|
||||||
-- Swtich file using clangd extension
|
-- Switch file using clangd extension
|
||||||
-- TODO: limit this to only filetypes supported by clangd
|
-- TODO: limit this to only filetypes supported by clangd
|
||||||
vim.keymap.set('n', '<leader>sf',
|
vim.keymap.set('n', '<leader>sf',
|
||||||
':ClangdSwitchSourceHeader<CR>', { silent = true })
|
':ClangdSwitchSourceHeader<CR>', { silent = true })
|
||||||
@@ -221,5 +243,15 @@ return {
|
|||||||
toggle_key_flip_floatwin_setting = true,
|
toggle_key_flip_floatwin_setting = true,
|
||||||
select_signature_key = '<C-l>',
|
select_signature_key = '<C-l>',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- When harper-ls is installed
|
||||||
|
local mason_registry = require('mason-registry')
|
||||||
|
if mason_registry.is_installed('harper-ls') then
|
||||||
|
-- Disable builtin spell mode highlighting
|
||||||
|
vim.cmd.highlight('SpellBad', 'NONE')
|
||||||
|
vim.cmd.highlight('SpellCap', 'NONE')
|
||||||
|
vim.cmd.highlight('SpellLocal', 'NONE')
|
||||||
|
vim.cmd.highlight('SpellRare', 'NONE')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
64
lua/plugins/debugger.lua
Normal file
64
lua/plugins/debugger.lua
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
return {
|
||||||
|
'mfussenegger/nvim-dap',
|
||||||
|
dependencies = {
|
||||||
|
'igorlfs/nvim-dap-view',
|
||||||
|
'kbenzie/mason.nvim',
|
||||||
|
'jay-babu/mason-nvim-dap.nvim',
|
||||||
|
'theHamsta/nvim-dap-virtual-text',
|
||||||
|
'Jorenar/nvim-dap-disasm',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local dap = require('dap')
|
||||||
|
|
||||||
|
-- Installation
|
||||||
|
local debug_adapters = {
|
||||||
|
'codelldb', -- C/C++/Rust/Zig
|
||||||
|
}
|
||||||
|
|
||||||
|
if vim.fn.executable('pip') == 1 then
|
||||||
|
table.insert(debug_adapters, 'python') -- Python
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.executable('go') == 1 then
|
||||||
|
table.insert(debug_adapters, 'delve') -- Go
|
||||||
|
end
|
||||||
|
|
||||||
|
require("mason-nvim-dap").setup({
|
||||||
|
ensure_installed = debug_adapters,
|
||||||
|
handlers = {},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- UI plugins
|
||||||
|
require('dap-view').setup({
|
||||||
|
auto_toggle = true,
|
||||||
|
})
|
||||||
|
require('nvim-dap-virtual-text').setup({})
|
||||||
|
require('dap-disasm').setup({
|
||||||
|
dapview_register = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||||
|
pattern = {
|
||||||
|
'dap-float',
|
||||||
|
},
|
||||||
|
callback = function(args)
|
||||||
|
vim.keymap.set("n", "q", "<C-w>q", { buffer = args.buf })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
local widgets = require('dap.ui.widgets')
|
||||||
|
|
||||||
|
-- Mappings
|
||||||
|
vim.keymap.set('n', '<leader>D', vim.cmd.DapViewToggle)
|
||||||
|
vim.keymap.set('n', '<F5>', dap.continue)
|
||||||
|
vim.keymap.set('n', '<F17>', dap.terminate) -- Shift-F5
|
||||||
|
vim.keymap.set('n', '<F9>', dap.toggle_breakpoint)
|
||||||
|
vim.keymap.set('n', '<F21>', vim.cmd.DapViewWatch) -- Shift-F9
|
||||||
|
vim.keymap.set('n', '<F41>', dap.restart) -- Ctrl-Shift-F5
|
||||||
|
vim.keymap.set('n', '<F34>', dap.run_to_cursor) -- Ctrl-F10
|
||||||
|
vim.keymap.set('n', '<F11>', dap.step_into)
|
||||||
|
vim.keymap.set('n', '<F23>', dap.step_out) -- Shift-F11
|
||||||
|
vim.keymap.set('n', '<F10>', dap.step_over)
|
||||||
|
vim.keymap.set('n', '<leader>K', widgets.hover)
|
||||||
|
end,
|
||||||
|
}
|
||||||
@@ -7,11 +7,15 @@ return {
|
|||||||
config = function()
|
config = function()
|
||||||
require('trouble').setup({})
|
require('trouble').setup({})
|
||||||
local opts = { remap = false }
|
local opts = { remap = false }
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
vim.keymap.set('n', '[d', function()
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
vim.diagnostic.jump({ count = -1, float = true })
|
||||||
|
end, opts)
|
||||||
|
vim.keymap.set('n', ']d', function()
|
||||||
|
vim.diagnostic.jump({ count = 1, float = true })
|
||||||
|
end, opts)
|
||||||
vim.keymap.set('n', '<leader>ds', vim.diagnostic.open_float, opts)
|
vim.keymap.set('n', '<leader>ds', vim.diagnostic.open_float, opts)
|
||||||
vim.keymap.set('n', '<leader>dq', function()
|
vim.keymap.set('n', '<leader>dq', function()
|
||||||
require('trouble').toggle()
|
require('trouble').toggle('diagnostics')
|
||||||
end, opts)
|
end, opts)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
{ 'tpope/vim-fugitive', lazy = false },
|
{ 'tpope/vim-fugitive', lazy = false },
|
||||||
|
{ 'tpope/vim-rhubarb', lazy = false },
|
||||||
{
|
{
|
||||||
'lewis6991/gitsigns.nvim',
|
'lewis6991/gitsigns.nvim',
|
||||||
config = function()
|
config = function()
|
||||||
|
|||||||
6
lua/plugins/mdx.lua
Normal file
6
lua/plugins/mdx.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
return {
|
||||||
|
'davidmh/mdx.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
},
|
||||||
|
}
|
||||||
64
lua/plugins/mux.lua
Normal file
64
lua/plugins/mux.lua
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
return {
|
||||||
|
'numToStr/Navigator.nvim',
|
||||||
|
config = function()
|
||||||
|
local navigator = require('Navigator')
|
||||||
|
navigator.setup({
|
||||||
|
disable_on_zoom = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
local augroup = vim.api.nvim_create_augroup('mux', { clear = true })
|
||||||
|
if vim.env.TMUX ~= nil then
|
||||||
|
-- Integrate tmux navigation flag
|
||||||
|
local navigation_flag =
|
||||||
|
'@vim' .. vim.fn.substitute(vim.env.TMUX_PANE, '%', '\\%', 'g')
|
||||||
|
local function set_navigation_flag()
|
||||||
|
vim.fn.system('tmux set-window-option ' .. navigation_flag .. ' 1')
|
||||||
|
end
|
||||||
|
local function unset_navigation_flag()
|
||||||
|
-- FIXME: Due to a regression this causes SIGABRT when RelWithDebInfo
|
||||||
|
-- vim.fn.system('tmux set-window-option -u ' .. navigation_flag)
|
||||||
|
-- https://github.com/neovim/neovim/issues/21856 contains a workaround
|
||||||
|
vim.fn.jobstart(
|
||||||
|
'tmux set-window-option -u ' .. navigation_flag, { detach = true })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- [Un]set tmux window option to detect when to change pane.
|
||||||
|
set_navigation_flag()
|
||||||
|
vim.api.nvim_create_autocmd('FocusGained', {
|
||||||
|
pattern = '*', group = augroup, callback = set_navigation_flag,
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd('VimLeave', {
|
||||||
|
pattern = '*', group = augroup, callback = unset_navigation_flag,
|
||||||
|
})
|
||||||
|
elseif vim.env.TERM_PROGRAM ~= nil and vim.env.TERM_PROGRAM == 'WezTerm' then
|
||||||
|
local function set_wezterm_user_var(in_vim)
|
||||||
|
local value = in_vim and '1' or '0'
|
||||||
|
local template = "\x1b]1337;SetUserVar=%s=%s\a"
|
||||||
|
local command = template:format('vim', vim.base64.encode(tostring(value)))
|
||||||
|
vim.api.nvim_chan_send(vim.v.stderr, command)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'VimEnter', 'VimResume' }, {
|
||||||
|
pattern = '*',
|
||||||
|
group = augroup,
|
||||||
|
callback = function()
|
||||||
|
set_wezterm_user_var(true)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'VimLeave', 'VimSuspend' }, {
|
||||||
|
pattern = '*',
|
||||||
|
group = augroup,
|
||||||
|
callback = function()
|
||||||
|
set_wezterm_user_var(false)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Map nativation bindings
|
||||||
|
vim.keymap.set('n', "<C-h>", navigator.left)
|
||||||
|
vim.keymap.set('n', "<C-j>", navigator.down)
|
||||||
|
vim.keymap.set('n', "<C-k>", navigator.up)
|
||||||
|
vim.keymap.set('n', "<C-l>", navigator.right)
|
||||||
|
end
|
||||||
|
}
|
||||||
29
lua/plugins/oil.lua
Normal file
29
lua/plugins/oil.lua
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
return {
|
||||||
|
'stevearc/oil.nvim',
|
||||||
|
dependencies = {
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
},
|
||||||
|
lazy = false,
|
||||||
|
config = function()
|
||||||
|
require('oil').setup({
|
||||||
|
keymaps = {
|
||||||
|
["g?"] = { "actions.show_help", mode = "n" },
|
||||||
|
["<CR>"] = "actions.select",
|
||||||
|
["<leader>l"] = "actions.refresh",
|
||||||
|
["-"] = { "actions.parent", mode = "n" },
|
||||||
|
["_"] = { "actions.open_cwd", mode = "n" },
|
||||||
|
["`"] = { "actions.cd", mode = "n" },
|
||||||
|
["~"] = { "actions.cd", opts = { scope = "tab" }, mode = "n" },
|
||||||
|
["gs"] = { "actions.change_sort", mode = "n" },
|
||||||
|
["gx"] = "actions.open_external",
|
||||||
|
["g."] = { "actions.toggle_hidden", mode = "n" },
|
||||||
|
["g\\"] = { "actions.toggle_trash", mode = "n" },
|
||||||
|
},
|
||||||
|
use_default_keymaps = false,
|
||||||
|
})
|
||||||
|
vim.keymap.set("n", "-", function()
|
||||||
|
local dir = vim.fn.expand("%:h")
|
||||||
|
vim.cmd.Oil(dir ~= "" and dir or ".")
|
||||||
|
end, {})
|
||||||
|
end
|
||||||
|
}
|
||||||
@@ -17,10 +17,20 @@ return {
|
|||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
end
|
end
|
||||||
end, { silent = true })
|
end, { silent = true })
|
||||||
vim.keymap.set({ 'i', 's' }, '<C-K>', function()
|
vim.keymap.set({ 'i', 's' }, '<C-k>', function()
|
||||||
if luasnip.jumpable(-1) then
|
if luasnip.jumpable(-1) then
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
end
|
end
|
||||||
end, { silent = true })
|
end, { silent = true })
|
||||||
|
vim.keymap.set({ "i", "s" }, "<C-n>", function()
|
||||||
|
if luasnip.choice_active() then
|
||||||
|
luasnip.change_choice(1)
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
vim.keymap.set({ "i", "s" }, "<C-p>", function()
|
||||||
|
if luasnip.choice_active() then
|
||||||
|
luasnip.change_choice(-1)
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
6
lua/plugins/table-mode.lua
Normal file
6
lua/plugins/table-mode.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
return {
|
||||||
|
'Kicamon/markdown-table-mode.nvim',
|
||||||
|
config = function()
|
||||||
|
require('markdown-table-mode').setup()
|
||||||
|
end
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ return {
|
|||||||
dependencies = {
|
dependencies = {
|
||||||
'nvim-lua/plenary.nvim',
|
'nvim-lua/plenary.nvim',
|
||||||
'nvim-telescope/telescope-fzy-native.nvim',
|
'nvim-telescope/telescope-fzy-native.nvim',
|
||||||
|
'nvim-telescope/telescope-live-grep-args.nvim',
|
||||||
'nvim-tree/nvim-web-devicons',
|
'nvim-tree/nvim-web-devicons',
|
||||||
'axkirillov/easypick.nvim',
|
'axkirillov/easypick.nvim',
|
||||||
'benfowler/telescope-luasnip.nvim',
|
'benfowler/telescope-luasnip.nvim',
|
||||||
@@ -16,11 +17,13 @@ return {
|
|||||||
['<C-s>'] = 'select_horizontal',
|
['<C-s>'] = 'select_horizontal',
|
||||||
['<C-h>'] = 'preview_scrolling_left',
|
['<C-h>'] = 'preview_scrolling_left',
|
||||||
['<C-l>'] = 'preview_scrolling_right',
|
['<C-l>'] = 'preview_scrolling_right',
|
||||||
|
['<C-q>'] = require("trouble.sources.telescope").open,
|
||||||
},
|
},
|
||||||
n = {
|
n = {
|
||||||
['<C-s>'] = 'select_horizontal',
|
['<C-s>'] = 'select_horizontal',
|
||||||
['<C-h>'] = 'preview_scrolling_left',
|
['<C-h>'] = 'preview_scrolling_left',
|
||||||
['<C-l>'] = 'preview_scrolling_right',
|
['<C-l>'] = 'preview_scrolling_right',
|
||||||
|
['<C-q>'] = require("trouble.sources.telescope").open,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
layout_config = {
|
layout_config = {
|
||||||
@@ -29,6 +32,7 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
telescope.load_extension('fzy_native')
|
telescope.load_extension('fzy_native')
|
||||||
|
telescope.load_extension('live_grep_args')
|
||||||
telescope.load_extension('luasnip')
|
telescope.load_extension('luasnip')
|
||||||
|
|
||||||
local builtin = require('telescope.builtin')
|
local builtin = require('telescope.builtin')
|
||||||
@@ -36,9 +40,11 @@ return {
|
|||||||
vim.keymap.set('n', '<leader>gF', builtin.find_files, opts)
|
vim.keymap.set('n', '<leader>gF', builtin.find_files, opts)
|
||||||
vim.keymap.set('n', '<leader>gf', builtin.git_files, opts)
|
vim.keymap.set('n', '<leader>gf', builtin.git_files, opts)
|
||||||
vim.keymap.set('n', '<leader>gg', builtin.live_grep, opts)
|
vim.keymap.set('n', '<leader>gg', builtin.live_grep, opts)
|
||||||
|
vim.keymap.set('n', '<leader>gG', telescope.extensions.live_grep_args.live_grep_args, opts)
|
||||||
vim.keymap.set('n', '<leader>gb', builtin.buffers, opts)
|
vim.keymap.set('n', '<leader>gb', builtin.buffers, opts)
|
||||||
vim.keymap.set('n', '<leader>gh', builtin.help_tags, opts)
|
vim.keymap.set('n', '<leader>gh', builtin.help_tags, opts)
|
||||||
vim.keymap.set('n', '<leader>bl', builtin.current_buffer_fuzzy_find, opts)
|
vim.keymap.set('n', '<leader>gl', builtin.current_buffer_fuzzy_find, opts)
|
||||||
|
vim.keymap.set('n', '<leader>gc', builtin.commands, opts)
|
||||||
|
|
||||||
require('easypick').setup({
|
require('easypick').setup({
|
||||||
pickers = { },
|
pickers = { },
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
return {
|
|
||||||
'alexghergh/nvim-tmux-navigation',
|
|
||||||
config = function()
|
|
||||||
local plugin = require('nvim-tmux-navigation')
|
|
||||||
plugin.setup({
|
|
||||||
disable_when_zoomed = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Integrate tmux navigation flag
|
|
||||||
local navigation_flag =
|
|
||||||
'@vim' .. vim.fn.substitute(vim.env.TMUX_PANE, '%', '\\%', 'g')
|
|
||||||
local function set_navigation_flag()
|
|
||||||
vim.fn.system('tmux set-window-option ' .. navigation_flag .. ' 1')
|
|
||||||
end
|
|
||||||
local function unset_navigation_flag()
|
|
||||||
-- FIXME: Due to a regression this causes SIGABRT when RelWithDebInfo
|
|
||||||
-- vim.fn.system('tmux set-window-option -u ' .. navigation_flag)
|
|
||||||
-- https://github.com/neovim/neovim/issues/21856 contains a workaround
|
|
||||||
vim.fn.jobstart(
|
|
||||||
'tmux set-window-option -u ' .. navigation_flag, { detach = true})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- [Un]set tmux window option to detect when to change pane.
|
|
||||||
set_navigation_flag()
|
|
||||||
local augroup = vim.api.nvim_create_augroup('tmux', { clear = true })
|
|
||||||
vim.api.nvim_create_autocmd('FocusGained', {
|
|
||||||
pattern = '*', group = augroup, callback = set_navigation_flag,
|
|
||||||
})
|
|
||||||
vim.api.nvim_create_autocmd('VimLeave', {
|
|
||||||
pattern = '*', group = augroup, callback = unset_navigation_flag,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Map nativation bindings
|
|
||||||
vim.keymap.set('n', "<C-h>", plugin.NvimTmuxNavigateLeft)
|
|
||||||
vim.keymap.set('n', "<C-j>", plugin.NvimTmuxNavigateDown)
|
|
||||||
vim.keymap.set('n', "<C-k>", plugin.NvimTmuxNavigateUp)
|
|
||||||
vim.keymap.set('n', "<C-l>", plugin.NvimTmuxNavigateRight)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
branch = 'master',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
{ 'nvim-treesitter/nvim-treesitter-context', opts = {} },
|
{ 'nvim-treesitter/nvim-treesitter-context', opts = {} },
|
||||||
@@ -62,6 +63,7 @@ return {
|
|||||||
'rst',
|
'rst',
|
||||||
'ssh_config',
|
'ssh_config',
|
||||||
'strace',
|
'strace',
|
||||||
|
'tablegen',
|
||||||
'tmux',
|
'tmux',
|
||||||
'toml',
|
'toml',
|
||||||
'vim',
|
'vim',
|
||||||
|
|||||||
@@ -34,10 +34,16 @@ local noice = {
|
|||||||
return {
|
return {
|
||||||
-- noice,
|
-- noice,
|
||||||
{
|
{
|
||||||
'tummetott/unimpaired.nvim',
|
'echasnovski/mini.comment',
|
||||||
config = function()
|
opts = {
|
||||||
require('unimpaired').setup({})
|
options = {
|
||||||
end
|
ignore_blank_line = true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'tpope/vim-unimpaired',
|
||||||
|
lazy = false,
|
||||||
},
|
},
|
||||||
{ 'stevearc/dressing.nvim' },
|
{ 'stevearc/dressing.nvim' },
|
||||||
{ 'kevinhwang91/nvim-bqf' },
|
{ 'kevinhwang91/nvim-bqf' },
|
||||||
|
|||||||
@@ -25,30 +25,17 @@ vim.api.nvim_create_autocmd('BufRead', {
|
|||||||
|
|
||||||
-- Start terminals in insert mode
|
-- Start terminals in insert mode
|
||||||
vim.api.nvim_create_autocmd('TermOpen', {
|
vim.api.nvim_create_autocmd('TermOpen', {
|
||||||
group = group, pattern = 'term://*',
|
group = group,
|
||||||
callback = function()
|
pattern = 'term://*',
|
||||||
|
callback = function(args)
|
||||||
|
-- nvim-dap/nvim-dap-view uses terminal buffers in the background which are
|
||||||
|
-- not visible, don't start insert mode if the dap-type variable exists.
|
||||||
|
local success, dap_type = pcall(vim.api.nvim_buf_get_var, args.buf, 'dap-type')
|
||||||
|
if success and dap_type then
|
||||||
|
return
|
||||||
|
end
|
||||||
vim.cmd.startinsert()
|
vim.cmd.startinsert()
|
||||||
end
|
end,
|
||||||
})
|
|
||||||
|
|
||||||
-- Don't show the line number column in terminal-insert mode
|
|
||||||
vim.api.nvim_create_autocmd('TermEnter', {
|
|
||||||
group = group, pattern = 'term://*',
|
|
||||||
callback = function()
|
|
||||||
vim.opt.number = false
|
|
||||||
vim.opt.relativenumber = false
|
|
||||||
vim.opt.signcolumn = 'no'
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
-- But do show the line number column in terminal-normal mode
|
|
||||||
vim.api.nvim_create_autocmd('TermLeave', {
|
|
||||||
group = group, pattern = 'term://*',
|
|
||||||
callback = function()
|
|
||||||
vim.opt.number = true
|
|
||||||
vim.opt.relativenumber = true
|
|
||||||
vim.opt.signcolumn = 'yes'
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Automatically press enter when the terminal process exit successfully
|
-- Automatically press enter when the terminal process exit successfully
|
||||||
|
|||||||
@@ -21,42 +21,58 @@ function build.set_dir(dirname)
|
|||||||
end
|
end
|
||||||
|
|
||||||
build.dir = build_dir
|
build.dir = build_dir
|
||||||
|
|
||||||
echo('Processing compile_commands.json with compdb ...', 'DiagnosticInfo')
|
|
||||||
local compile_commands = current_dir .. '/compile_commands.json'
|
local compile_commands = current_dir .. '/compile_commands.json'
|
||||||
-- Post-process compile_commands.json with compdb as an async job to avoid
|
|
||||||
-- blocking the user interface
|
|
||||||
vim.fn.jobstart(
|
|
||||||
'compdb -p ' .. build.dir .. ' list > ' .. compile_commands, {
|
|
||||||
|
|
||||||
-- Restart clangd language server
|
if vim.fn.executable('compdb') == 1 then
|
||||||
-- TODO: Configure cmake language server?
|
echo('Processing compile_commands.json with compdb ...', 'DiagnosticInfo')
|
||||||
on_exit = function()
|
-- Post-process compile_commands.json with compdb as an async job to avoid
|
||||||
vim.cmd.LspRestart('clangd')
|
-- blocking the user interface
|
||||||
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
|
vim.fn.jobstart(
|
||||||
end,
|
'compdb -p ' .. build.dir .. ' list > ' .. compile_commands, {
|
||||||
|
|
||||||
-- Display any error messages to the user
|
-- Restart clangd language server
|
||||||
on_stderr = function(_, output, _)
|
on_exit = function()
|
||||||
-- Remove any lines containing a compdb warning
|
-- This is a callback so doesn't run on the main thread which causes
|
||||||
local error = {}
|
-- issues for running commands, so schedule that on the main thread.
|
||||||
local warning = 'WARNING:compdb'
|
vim.schedule(function()
|
||||||
for _, line in ipairs(output) do
|
vim.cmd('LspRestart clangd')
|
||||||
if string.sub(line, 1, #warning) ~= warning then
|
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
|
||||||
table.insert(error, line)
|
end)
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- Display any error messages to the user
|
||||||
|
on_stderr = function(_, output, _)
|
||||||
|
-- Remove any lines containing a compdb warning
|
||||||
|
local error = {}
|
||||||
|
local warning = 'WARNING:compdb'
|
||||||
|
for _, line in ipairs(output) do
|
||||||
|
if string.sub(line, 1, #warning) ~= warning then
|
||||||
|
table.insert(error, line)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Display the error message if there was one
|
-- Display the error message if there was one
|
||||||
if table.maxn(error) > 0 then
|
if table.maxn(error) > 0 then
|
||||||
echo(vim.fn.join(error, '\n'), 'Error')
|
echo(vim.fn.join(error, '\n'), 'Error')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
stderr_buffered = true,
|
stderr_buffered = true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
else
|
||||||
|
vim.uv.fs_copyfile(build_dir .. '/compile_commands.json', compile_commands, nil,
|
||||||
|
function()
|
||||||
|
-- This is a callback so doesn't run on the main thread which causes
|
||||||
|
-- issues for running commands, so schedule that on the main thread.
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.cmd('LspRestart clangd')
|
||||||
|
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function build.select_dir(callback)
|
function build.select_dir(callback)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-- :RString strip white psace from right of all lines, ranges supported
|
-- :RStrip strip white space from right of all lines, ranges supported
|
||||||
vim.api.nvim_create_user_command('RStrip', function(opts)
|
vim.api.nvim_create_user_command('RStrip', function(opts)
|
||||||
local pos = vim.fn.getcurpos(vim.api.nvim_get_current_win())
|
local pos = vim.fn.getcurpos(vim.api.nvim_get_current_win())
|
||||||
local range = opts.line1 .. ',' .. opts.line2
|
local range = opts.line1 .. ',' .. opts.line2
|
||||||
@@ -7,6 +7,15 @@ vim.api.nvim_create_user_command('RStrip', function(opts)
|
|||||||
vim.fn.setpos('.', pos)
|
vim.fn.setpos('.', pos)
|
||||||
end, { range = '%' })
|
end, { range = '%' })
|
||||||
|
|
||||||
|
-- :LStrip strip white space from left of all lines, ranges supported
|
||||||
|
vim.api.nvim_create_user_command('LStrip', function(opts)
|
||||||
|
local pos = vim.fn.getcurpos(vim.api.nvim_get_current_win())
|
||||||
|
local range = opts.line1 .. ',' .. opts.line2
|
||||||
|
vim.cmd.execute("'" .. range .. 's/^\\s\\+//e' .. "'")
|
||||||
|
vim.cmd.nohlsearch()
|
||||||
|
vim.fn.setpos('.', pos)
|
||||||
|
end, { range = '%' })
|
||||||
|
|
||||||
-- :TabWidth set the tab width for the current buffer
|
-- :TabWidth set the tab width for the current buffer
|
||||||
vim.api.nvim_create_user_command('TabWidth', function(opts)
|
vim.api.nvim_create_user_command('TabWidth', function(opts)
|
||||||
-- Set the tab width for the current filetype
|
-- Set the tab width for the current filetype
|
||||||
@@ -42,7 +51,7 @@ vim.api.nvim_create_user_command('Remove', function(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Actually remove the file using the selecte callback.
|
-- Actually remove the file using the selected callback.
|
||||||
vim.loop.fs_unlink(path, callback)
|
vim.loop.fs_unlink(path, callback)
|
||||||
end, { bang = true })
|
end, { bang = true })
|
||||||
|
|
||||||
@@ -134,13 +143,14 @@ vim.api.nvim_create_user_command('Rg', function(opts)
|
|||||||
elseif #search == 0 then
|
elseif #search == 0 then
|
||||||
search = vim.fn.expand('<cword>')
|
search = vim.fn.expand('<cword>')
|
||||||
end
|
end
|
||||||
local grep_opts = { search = search}
|
local grep_opts = { search = search }
|
||||||
if opts.bang then
|
if opts.bang then
|
||||||
grep_opts['use_regex'] = true
|
grep_opts['use_regex'] = true
|
||||||
end
|
end
|
||||||
require('telescope.builtin').grep_string(grep_opts)
|
require('telescope.builtin').grep_string(grep_opts)
|
||||||
end, { bang = true, range = true, nargs = '*' })
|
end, { bang = true, range = true, nargs = '*' })
|
||||||
|
|
||||||
|
-- :PreProcIfWrap wraps the given range of lines in #if 0 / #endif.
|
||||||
vim.api.nvim_create_user_command('PreProcIfWrap', function(opts)
|
vim.api.nvim_create_user_command('PreProcIfWrap', function(opts)
|
||||||
local buffer = vim.api.nvim_get_current_buf()
|
local buffer = vim.api.nvim_get_current_buf()
|
||||||
vim.api.nvim_buf_set_lines(
|
vim.api.nvim_buf_set_lines(
|
||||||
@@ -150,3 +160,80 @@ vim.api.nvim_create_user_command('PreProcIfWrap', function(opts)
|
|||||||
local window = vim.api.nvim_get_current_win()
|
local window = vim.api.nvim_get_current_win()
|
||||||
vim.api.nvim_win_set_cursor(window, { opts.line1, 5 })
|
vim.api.nvim_win_set_cursor(window, { opts.line1, 5 })
|
||||||
end, { range = true })
|
end, { range = true })
|
||||||
|
|
||||||
|
-- :CheckboxToggle toggles GitHub Flavoured Markdown style checkboxes.
|
||||||
|
vim.api.nvim_create_user_command('CheckboxToggle', function(opts)
|
||||||
|
local linenr = vim.fn.line('.')
|
||||||
|
local line = vim.fn.getline(linenr)
|
||||||
|
local pos = string.find(line, '[ ]', 0, true)
|
||||||
|
if pos == nil then
|
||||||
|
pos = string.find(line, '[x]', 0, true)
|
||||||
|
if pos == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local x = string.sub(line, pos + 1, pos + 1)
|
||||||
|
if x == 'x' then x = ' ' else x = 'x' end
|
||||||
|
vim.fn.setline(linenr, string.sub(line, 1, pos) .. x .. string.sub(line, pos + 2))
|
||||||
|
end, {})
|
||||||
|
|
||||||
|
-- :Tac reverse the order of lines in the selected range or the whole file if
|
||||||
|
-- no range is specificed, works as if executing :!tac but purely in Lua making
|
||||||
|
-- it cross-platform.
|
||||||
|
vim.api.nvim_create_user_command('Tac', function(opts)
|
||||||
|
local buffer = vim.api.nvim_get_current_buf()
|
||||||
|
local line1 = opts.line1 - 1
|
||||||
|
local line2 = opts.line2
|
||||||
|
if opts.range == 0 then
|
||||||
|
line1 = 0
|
||||||
|
line2 = -1
|
||||||
|
end
|
||||||
|
print(opts.range, line1, line2)
|
||||||
|
local lines = vim.api.nvim_buf_get_lines(buffer, line1, line2, false)
|
||||||
|
if lines and #lines > 1 then
|
||||||
|
local temp = nil
|
||||||
|
for n = 1, math.floor(#lines / 2) do
|
||||||
|
temp = lines[n]
|
||||||
|
lines[n] = lines[#lines - (n - 1)]
|
||||||
|
lines[#lines - (n - 1)] = temp
|
||||||
|
end
|
||||||
|
vim.api.nvim_buf_set_lines(buffer, line1, line2, true, lines)
|
||||||
|
end
|
||||||
|
end, { range = true })
|
||||||
|
|
||||||
|
-- :DiagnosticToggle to disable diagnostics when enabled and vise versa.
|
||||||
|
vim.api.nvim_create_user_command('DiagnosticToggle', function(_)
|
||||||
|
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||||
|
end, {})
|
||||||
|
|
||||||
|
-- -- :QuickFiles creates a floating window for the user to input a list of files
|
||||||
|
-- -- then populates and opens the quickfix list.
|
||||||
|
-- vim.api.nvim_create_user_command('QuickFiles', function()
|
||||||
|
-- -- Create scratch buffer & set options
|
||||||
|
-- local buffer = vim.api.nvim_create_buf(false, true)
|
||||||
|
-- vim.bo[buffer].errorformat = "%f"
|
||||||
|
|
||||||
|
-- -- Calculate floating window dimensions
|
||||||
|
-- local ui = vim.api.nvim_list_uis()[1]
|
||||||
|
-- local width = math.floor(ui.width * 0.6)
|
||||||
|
-- local height = math.floor(ui.height * 0.4)
|
||||||
|
|
||||||
|
-- -- Create the floating window
|
||||||
|
-- local window = vim.api.nvim_open_win(buffer, true, {
|
||||||
|
-- relative = 'editor',
|
||||||
|
-- width = width,
|
||||||
|
-- height = height,
|
||||||
|
-- row = math.floor((ui.height - height) / 2),
|
||||||
|
-- col = math.floor((ui.width - width) / 2),
|
||||||
|
-- style = 'minimal',
|
||||||
|
-- border = 'rounded',
|
||||||
|
-- title = 'QuickFiles',
|
||||||
|
-- title_pos = "center",
|
||||||
|
-- })
|
||||||
|
|
||||||
|
-- vim.keymap.set('n', 'q', function()
|
||||||
|
-- vim.cmd.cbuffer()
|
||||||
|
-- vim.api.nvim_win_close(window, true)
|
||||||
|
-- vim.cmd.cwindow()
|
||||||
|
-- end, { buffer = buffer, nowait = true, silent = true })
|
||||||
|
-- end, {})
|
||||||
|
|||||||
@@ -47,3 +47,6 @@ vim.keymap.set('t', '<C-w><C-a>', '<C-\\><C-n>:Asm<CR>', opts)
|
|||||||
-- Mappings to grep for then fuzzy find the word under the cursor or visual selection
|
-- Mappings to grep for then fuzzy find the word under the cursor or visual selection
|
||||||
vim.keymap.set('n', '<leader>rg', ':Rg<CR>', opts)
|
vim.keymap.set('n', '<leader>rg', ':Rg<CR>', opts)
|
||||||
vim.keymap.set('v', '<leader>rg', ":'<,'>Rg<CR>", opts)
|
vim.keymap.set('v', '<leader>rg', ":'<,'>Rg<CR>", opts)
|
||||||
|
|
||||||
|
-- Mapping to toggle checkboxes
|
||||||
|
vim.keymap.set('n', '<leader><CR>', ':CheckboxToggle<CR>', opts)
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
-- Disable banner
|
|
||||||
vim.g.netrw_banner = 0
|
|
||||||
|
|
||||||
-- Fix gx when running inside WSL
|
|
||||||
if vim.env.WSLENV then
|
|
||||||
vim.g.netrw_browsex_viewer = 'cmd.exe /C start'
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Map - key to open netrw in current files parent directory
|
|
||||||
vim.keymap.set('n', '-', function()
|
|
||||||
-- Get the filename before invoking netrw
|
|
||||||
local filename = vim.fn.expand('%:t')
|
|
||||||
local directory = vim.fn.expand('%:hp')
|
|
||||||
|
|
||||||
if directory == '' then
|
|
||||||
directory = vim.fn.getcwd()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Invoke netrw on the directory containing the current file
|
|
||||||
vim.fn.execute(string.format("edit %s", directory))
|
|
||||||
if filename ~= '' then
|
|
||||||
-- In the netrw buffer, move the cursor to the first character of filename
|
|
||||||
vim.fn.search('\\<' .. filename .. '\\>')
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Unmap <C-l> in netrw buffers so it can be used for natigation
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
|
||||||
pattern = 'netrw',
|
|
||||||
group = vim.api.nvim_create_augroup('netrw_unmap', {}),
|
|
||||||
callback = function()
|
|
||||||
local buffer = vim.api.nvim_get_current_buf()
|
|
||||||
if vim.fn.hasmapto('<Plug>NetrwRefresh') == 1 then
|
|
||||||
vim.keymap.del('n', '<C-l>', { buffer = buffer })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
@@ -3,6 +3,12 @@ vim.g.loaded_node_provider = 0
|
|||||||
vim.g.loaded_perl_provider = 0
|
vim.g.loaded_perl_provider = 0
|
||||||
vim.g.loaded_ruby_provider = 0
|
vim.g.loaded_ruby_provider = 0
|
||||||
|
|
||||||
|
if vim.env.TMUX ~= nil and vim.env.WAYLAND_DISPLAY ~= nil then
|
||||||
|
-- Use tmux instead of wl-clipboard on Wayland to avoid annoying notification
|
||||||
|
-- popups when copying/pasting from the system clipboard.
|
||||||
|
vim.g.clipboard = "tmux"
|
||||||
|
end
|
||||||
|
|
||||||
-- Keep cursor from buffer edges
|
-- Keep cursor from buffer edges
|
||||||
vim.opt.sidescrolloff = 5
|
vim.opt.sidescrolloff = 5
|
||||||
|
|
||||||
@@ -40,6 +46,9 @@ vim.opt.completeopt = 'menu'
|
|||||||
-- Set window title to titlestring
|
-- Set window title to titlestring
|
||||||
vim.opt.title = true
|
vim.opt.title = true
|
||||||
|
|
||||||
|
-- Use rounded borders for floating windows
|
||||||
|
vim.o.winborder = 'rounded'
|
||||||
|
|
||||||
-- Don't show mode in command line
|
-- Don't show mode in command line
|
||||||
vim.opt.showmode = false
|
vim.opt.showmode = false
|
||||||
|
|
||||||
@@ -69,7 +78,7 @@ vim.opt.splitbelow = true
|
|||||||
vim.opt.splitright = true
|
vim.opt.splitright = true
|
||||||
|
|
||||||
-- Use existing windows and tabs when jumping to errors
|
-- Use existing windows and tabs when jumping to errors
|
||||||
vim.opt.switchbuf = 'usetab'
|
vim.opt.switchbuf = 'usetab,uselast'
|
||||||
|
|
||||||
-- Automatically write changes to files
|
-- Automatically write changes to files
|
||||||
vim.opt.autowrite = true
|
vim.opt.autowrite = true
|
||||||
@@ -81,13 +90,8 @@ vim.opt.joinspaces = false
|
|||||||
vim.opt.foldlevel = 20
|
vim.opt.foldlevel = 20
|
||||||
vim.opt.foldmethod = 'expr'
|
vim.opt.foldmethod = 'expr'
|
||||||
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
|
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
|
vim.opt.foldtext = ''
|
||||||
vim.opt.fillchars = 'fold: '
|
vim.opt.fillchars = 'fold: '
|
||||||
-- FIXME: Replace this with transparent fold text in 0.10
|
|
||||||
-- https://github.com/neovim/neovim/pull/20750
|
|
||||||
function _G.fold_text()
|
|
||||||
return vim.fn.getline(vim.v.foldstart)
|
|
||||||
end
|
|
||||||
vim.opt.foldtext = 'v:lua.fold_text()'
|
|
||||||
|
|
||||||
-- Enable all mouse features
|
-- Enable all mouse features
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = 'a'
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ local function get_mode()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Display cusor line/total and column
|
-- Display cusor line/total and column
|
||||||
local position = '# ☰ %l/%L %2c '
|
local position = '# %l/%L:%2c '
|
||||||
|
|
||||||
-- Construct a statusline for special buffer types.
|
-- Construct a statusline for special buffer types.
|
||||||
local function special(group, name, title)
|
local function special(group, name, title)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ local snip = luasnip.snippet
|
|||||||
local text = luasnip.text_node
|
local text = luasnip.text_node
|
||||||
-- local isn = luasnip.indent_snippet_node
|
-- local isn = luasnip.indent_snippet_node
|
||||||
-- local t = luasnip.text_node
|
-- local t = luasnip.text_node
|
||||||
local insert = luasnip.insert_node
|
local ins = luasnip.insert_node
|
||||||
local func = luasnip.function_node
|
local func = luasnip.function_node
|
||||||
-- local c = luasnip.choice_node
|
-- local c = luasnip.choice_node
|
||||||
-- local d = luasnip.dynamic_node
|
-- local d = luasnip.dynamic_node
|
||||||
@@ -67,7 +67,7 @@ for _, name in ipairs({ 'fixme', 'todo', 'hack', 'warn', 'note' }) do
|
|||||||
snip(name, {
|
snip(name, {
|
||||||
func(comment_prefix),
|
func(comment_prefix),
|
||||||
text(string.upper(name) .. ': '),
|
text(string.upper(name) .. ': '),
|
||||||
insert(0),
|
ins(0),
|
||||||
func(comment_suffix),
|
func(comment_suffix),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,25 +1,60 @@
|
|||||||
# C LuaSnip Snippets
|
-- C LuaSnip Snippets
|
||||||
|
|
||||||
local luasnip = require('luasnip')
|
local luasnip = require('luasnip')
|
||||||
local snip = luasnip.snippet
|
local snippet = luasnip.snippet
|
||||||
local text = luasnip.text_node
|
local text = luasnip.text_node
|
||||||
local insert = luasnip.insert_node
|
local insert = luasnip.insert_node
|
||||||
local func = luasnip.function_node
|
local func = luasnip.function_node
|
||||||
|
local choice = luasnip.choice_node
|
||||||
|
local dynamic = luasnip.dynamic_node
|
||||||
|
local restore = luasnip.restore_node
|
||||||
|
local snip = luasnip.snippet_node
|
||||||
local key = require("luasnip.nodes.key_indexer").new_key
|
local key = require("luasnip.nodes.key_indexer").new_key
|
||||||
|
|
||||||
|
local function getIncludeGuardName()
|
||||||
|
local filename = vim.fn.expand('%'):gsub('[^%w_]', '_'):upper()
|
||||||
|
return filename .. '_INCLUDED'
|
||||||
|
end
|
||||||
|
|
||||||
local snippets = {
|
local snippets = {
|
||||||
snip('#include', {
|
|
||||||
|
snippet('#include', {
|
||||||
text('#include '),
|
text('#include '),
|
||||||
insert(1, '<', { key = 'open' }),
|
choice(1, {
|
||||||
insert(2, 'header'),
|
snip(nil, { text('<'), restore(1, 'header'), text('>') }),
|
||||||
func(function(args)
|
snip(nil, { text('"'), restore(1, 'header'), text('"') }),
|
||||||
if args[1][1] == '<' then
|
}),
|
||||||
return '>'
|
}, { stored = { ['header'] = insert(1, 'header') } }),
|
||||||
else
|
|
||||||
return '"'
|
snippet('once', {
|
||||||
end
|
text('#ifndef '),
|
||||||
end, key('open')),
|
func(function(opts)
|
||||||
|
return opts[1][1]
|
||||||
|
end, key('guard')),
|
||||||
|
text({ '', '#define ' }),
|
||||||
|
dynamic(1, function()
|
||||||
|
return snip(nil, {
|
||||||
|
insert(1, getIncludeGuardName(), { key = 'guard' }),
|
||||||
|
})
|
||||||
|
end),
|
||||||
|
text({ '', '', '', }),
|
||||||
|
insert(0, ''),
|
||||||
|
text({ '', '', '#endif // ' }),
|
||||||
|
func(function(opts)
|
||||||
|
return opts[1][1]
|
||||||
|
end, key('guard')),
|
||||||
|
}, {}),
|
||||||
|
|
||||||
|
-- Doxygen
|
||||||
|
snippet('p', {
|
||||||
|
text('@param'),
|
||||||
|
choice(1, { text('[in]'), text('[out]'), text('[in,out]'), text('') }),
|
||||||
|
text(' '),
|
||||||
|
insert(2, 'name'),
|
||||||
|
text(' '),
|
||||||
|
insert(0, 'desc'),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return snippets
|
return snippets
|
||||||
|
|||||||
@@ -4,3 +4,13 @@ snippet main
|
|||||||
int main(${1:int argc, const char **argv}) {
|
int main(${1:int argc, const char **argv}) {
|
||||||
$0
|
$0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Doxygen
|
||||||
|
snippet b
|
||||||
|
@brief ${0:desc}
|
||||||
|
|
||||||
|
snippet r
|
||||||
|
@return ${0:desc}
|
||||||
|
|
||||||
|
snippet rv
|
||||||
|
@retval ${1:val} ${0:desc}
|
||||||
|
|||||||
@@ -1,5 +1,48 @@
|
|||||||
# C++ LuaSnip Snippets
|
-- C++ LuaSnip Snippets
|
||||||
|
|
||||||
local luasnip = require('luasnip')
|
local luasnip = require('luasnip')
|
||||||
|
|
||||||
luasnip.filetype_extend('cpp', { 'c' })
|
luasnip.filetype_extend('cpp', { 'c' })
|
||||||
|
local snip = luasnip.snippet
|
||||||
|
local text = luasnip.text_node
|
||||||
|
local ins = luasnip.insert_node
|
||||||
|
local dyn = luasnip.dynamic_node
|
||||||
|
local node = luasnip.snippet_node
|
||||||
|
local key = require("luasnip.nodes.key_indexer").new_key
|
||||||
|
|
||||||
|
local snippets = {
|
||||||
|
|
||||||
|
snip('for', {
|
||||||
|
text('for ('),
|
||||||
|
ins(1, 'auto'),
|
||||||
|
text(' '),
|
||||||
|
ins(2, 'index'),
|
||||||
|
text(' '),
|
||||||
|
ins(3, '='),
|
||||||
|
dyn(4, function(args)
|
||||||
|
local choice = args[2][1]
|
||||||
|
if choice == '=' then -- index based for loop
|
||||||
|
local var = args[1][1]
|
||||||
|
return node(nil, {
|
||||||
|
text(' '),
|
||||||
|
ins(1, '0'),
|
||||||
|
text('; ' .. var .. ' < '),
|
||||||
|
ins(2, 'count'),
|
||||||
|
text('; '),
|
||||||
|
ins(3, var .. '++'),
|
||||||
|
})
|
||||||
|
elseif choice == ':' then -- range based for loop
|
||||||
|
return node(nil, {
|
||||||
|
text(' '),
|
||||||
|
ins(1, 'container')
|
||||||
|
})
|
||||||
|
end
|
||||||
|
return node(nil, {})
|
||||||
|
end, { 2, 3 }, key('var')),
|
||||||
|
text({ ') {', '\t' }),
|
||||||
|
ins(0, ''),
|
||||||
|
text({ '', '}' })
|
||||||
|
}),
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return snippets
|
||||||
|
|||||||
@@ -2,16 +2,6 @@
|
|||||||
|
|
||||||
extends c
|
extends c
|
||||||
|
|
||||||
snippet for Range based
|
|
||||||
for (${1:auto} ${2:value} : ${3:container}) {
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
|
|
||||||
snippet for Index based
|
|
||||||
for (${1:int} i = ${2:0}; i < ${3:count}; i++) {
|
|
||||||
$0
|
|
||||||
}
|
|
||||||
|
|
||||||
snippet namespace
|
snippet namespace
|
||||||
namespace ${1} {
|
namespace ${1} {
|
||||||
$0
|
$0
|
||||||
|
|||||||
@@ -6,3 +6,8 @@ snippet main
|
|||||||
func main() {
|
func main() {
|
||||||
$0
|
$0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snippet err
|
||||||
|
if err != nil {
|
||||||
|
$0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user