Compare commits
48 Commits
0471dd67c4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ba5fd1c33b | |||
| ff14f16bbd | |||
| 00b5d44396 | |||
| 9a6765df45 | |||
| 280c00b272 | |||
| 31a03cac7b | |||
| 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 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
lazy-lock.json
|
lazy-lock.json
|
||||||
spell/*.spl
|
spell/*.spl
|
||||||
|
lua/local.lua
|
||||||
|
|||||||
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'
|
||||||
13
init.lua
13
init.lua
@@ -1,8 +1,19 @@
|
|||||||
|
vim.loader.enable()
|
||||||
|
|
||||||
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.uv.fs_stat(lazypath) then
|
||||||
vim.fn.system({ 'git', 'clone', '--filter=blob:none',
|
vim.fn.system({ 'git', 'clone', '--filter=blob:none',
|
||||||
'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath })
|
'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath })
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ local kanagawa = {
|
|||||||
-- Don't lighlight TODO specially in comments
|
-- Don't lighlight TODO specially in comments
|
||||||
for _, todo_group in pairs({
|
for _, todo_group in pairs({
|
||||||
'confTodo',
|
'confTodo',
|
||||||
|
'mojoTodo',
|
||||||
'ps1CommentTodo',
|
'ps1CommentTodo',
|
||||||
|
'pythonTodo',
|
||||||
'zshTodo',
|
'zshTodo',
|
||||||
}) do
|
}) do
|
||||||
vim.cmd.highlight('link ' .. todo_group .. ' Comment')
|
vim.cmd.highlight('link ' .. todo_group .. ' Comment')
|
||||||
|
|||||||
@@ -1,51 +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', -- Python
|
|
||||||
}
|
|
||||||
for _, package in ipairs(ensure_install_from_pip) do
|
|
||||||
table.insert(ensure_installed, package)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.fn.executable('go') == 1 then
|
|
||||||
local ensure_installed_from_go = {
|
|
||||||
'gopls', -- Go
|
|
||||||
}
|
|
||||||
for _, package in ipairs(ensure_installed_from_go) 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 = {
|
||||||
@@ -81,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' },
|
||||||
},
|
},
|
||||||
@@ -100,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/'),
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -111,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')
|
||||||
@@ -155,7 +175,7 @@ return {
|
|||||||
},
|
},
|
||||||
|
|
||||||
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)
|
||||||
@@ -173,7 +193,7 @@ return {
|
|||||||
documentation = cmp.config.window.bordered(),
|
documentation = cmp.config.window.bordered(),
|
||||||
},
|
},
|
||||||
|
|
||||||
preselect = 'none', -- Don't preselect completions suggested by source
|
preselect = 'None', -- Don't preselect completions suggested by source
|
||||||
})
|
})
|
||||||
require("cmp_git").setup({})
|
require("cmp_git").setup({})
|
||||||
|
|
||||||
@@ -204,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 })
|
||||||
@@ -229,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,
|
||||||
|
}
|
||||||
@@ -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',
|
||||||
|
},
|
||||||
|
}
|
||||||
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
|
||||||
|
}
|
||||||
@@ -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 = {} },
|
||||||
@@ -97,5 +98,10 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Keymaps
|
||||||
|
vim.keymap.set('n', '<leader>fm', function()
|
||||||
|
vim.o.foldmethod = 'expr'
|
||||||
|
end, {})
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,18 @@ local noice = {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
-- noice,
|
-- noice,
|
||||||
{ 'echasnovski/mini.comment', opts = { options = { ignore_blank_line = true } } },
|
|
||||||
{
|
{
|
||||||
'idanarye/nvim-impairative',
|
'echasnovski/mini.comment',
|
||||||
config = function()
|
opts = {
|
||||||
require('impairative').setup({})
|
options = {
|
||||||
require('impairative.replicate-unimpaired')()
|
ignore_blank_line = true,
|
||||||
end},
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'tpope/vim-unimpaired',
|
||||||
|
lazy = false,
|
||||||
|
},
|
||||||
{ 'stevearc/dressing.nvim' },
|
{ 'stevearc/dressing.nvim' },
|
||||||
{ 'kevinhwang91/nvim-bqf' },
|
{ 'kevinhwang91/nvim-bqf' },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +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,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Automatically press enter when the terminal process exit successfully
|
-- Automatically press enter when the terminal process exit successfully
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ vim.api.nvim_create_user_command('Remove', function(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Actually remove the file using the selected callback.
|
-- Actually remove the file using the selected callback.
|
||||||
vim.loop.fs_unlink(path, callback)
|
vim.uv.fs_unlink(path, callback)
|
||||||
end, { bang = true })
|
end, { bang = true })
|
||||||
|
|
||||||
-- :Move the file associated with the current buffer
|
-- :Move the file associated with the current buffer
|
||||||
@@ -62,7 +62,7 @@ vim.api.nvim_create_user_command('Move', function(opts)
|
|||||||
if vim.fn.isdirectory(dest) ~= 0 then
|
if vim.fn.isdirectory(dest) ~= 0 then
|
||||||
dest = vim.fn.resolve(dest .. '/' .. vim.fn.expand('%:t'))
|
dest = vim.fn.resolve(dest .. '/' .. vim.fn.expand('%:t'))
|
||||||
end
|
end
|
||||||
vim.loop.fs_rename(source, dest, function(err, success)
|
vim.uv.fs_rename(source, dest, function(err, success)
|
||||||
if success then
|
if success then
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
vim.cmd.edit(dest)
|
vim.cmd.edit(dest)
|
||||||
@@ -87,7 +87,7 @@ vim.api.nvim_create_user_command('Rename', function(opts)
|
|||||||
dest = vim.fn.resolve(dir .. '/' .. opts.args)
|
dest = vim.fn.resolve(dir .. '/' .. opts.args)
|
||||||
end
|
end
|
||||||
local buffer = vim.api.nvim_get_current_buf()
|
local buffer = vim.api.nvim_get_current_buf()
|
||||||
vim.loop.fs_rename(source, dest, function(err, success)
|
vim.uv.fs_rename(source, dest, function(err, success)
|
||||||
if not success then
|
if not success then
|
||||||
error(err)
|
error(err)
|
||||||
else
|
else
|
||||||
@@ -206,34 +206,34 @@ vim.api.nvim_create_user_command('DiagnosticToggle', function(_)
|
|||||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
-- :QuickFiles creates a floating window for the user to input a list of files
|
-- -- :QuickFiles creates a floating window for the user to input a list of files
|
||||||
-- then populates and opens the quickfix list.
|
-- -- then populates and opens the quickfix list.
|
||||||
vim.api.nvim_create_user_command('QuickFiles', function()
|
-- vim.api.nvim_create_user_command('QuickFiles', function()
|
||||||
-- Create scratch buffer & set options
|
-- -- Create scratch buffer & set options
|
||||||
local buffer = vim.api.nvim_create_buf(false, true)
|
-- local buffer = vim.api.nvim_create_buf(false, true)
|
||||||
vim.bo[buffer].errorformat = "%f"
|
-- vim.bo[buffer].errorformat = "%f"
|
||||||
|
|
||||||
-- Calculate floating window dimensions
|
-- -- Calculate floating window dimensions
|
||||||
local ui = vim.api.nvim_list_uis()[1]
|
-- local ui = vim.api.nvim_list_uis()[1]
|
||||||
local width = math.floor(ui.width * 0.6)
|
-- local width = math.floor(ui.width * 0.6)
|
||||||
local height = math.floor(ui.height * 0.4)
|
-- local height = math.floor(ui.height * 0.4)
|
||||||
|
|
||||||
-- Create the floating window
|
-- -- Create the floating window
|
||||||
local window = vim.api.nvim_open_win(buffer, true, {
|
-- local window = vim.api.nvim_open_win(buffer, true, {
|
||||||
relative = 'editor',
|
-- relative = 'editor',
|
||||||
width = width,
|
-- width = width,
|
||||||
height = height,
|
-- height = height,
|
||||||
row = math.floor((ui.height - height) / 2),
|
-- row = math.floor((ui.height - height) / 2),
|
||||||
col = math.floor((ui.width - width) / 2),
|
-- col = math.floor((ui.width - width) / 2),
|
||||||
style = 'minimal',
|
-- style = 'minimal',
|
||||||
border = 'rounded',
|
-- border = 'rounded',
|
||||||
title = 'QuickFiles',
|
-- title = 'QuickFiles',
|
||||||
title_pos = "center",
|
-- title_pos = "center",
|
||||||
})
|
-- })
|
||||||
|
|
||||||
vim.keymap.set('n', 'q', function()
|
-- vim.keymap.set('n', 'q', function()
|
||||||
vim.cmd.cbuffer()
|
-- vim.cmd.cbuffer()
|
||||||
vim.api.nvim_win_close(window, true)
|
-- vim.api.nvim_win_close(window, true)
|
||||||
vim.cmd.cwindow()
|
-- vim.cmd.cwindow()
|
||||||
end, { buffer = buffer, nowait = true, silent = true })
|
-- end, { buffer = buffer, nowait = true, silent = true })
|
||||||
end, {})
|
-- end, {})
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ vim.keymap.set('', '<leader>p', '"+p', opts)
|
|||||||
vim.keymap.set('', '<leader>P', '"+P', opts)
|
vim.keymap.set('', '<leader>P', '"+P', opts)
|
||||||
|
|
||||||
-- Undo neovim's default mapping of Y to y$
|
-- Undo neovim's default mapping of Y to y$
|
||||||
vim.cmd.unmap('Y')
|
vim.keymap.del('n', 'Y')
|
||||||
|
|
||||||
-- Make nvim :terminal more like vim :terminal
|
-- Make nvim :terminal more like vim :terminal
|
||||||
vim.keymap.set('t', '<C-w>N', '<C-\\><C-n>', opts)
|
vim.keymap.set('t', '<C-w>N', '<C-\\><C-n>', opts)
|
||||||
@@ -50,3 +50,10 @@ vim.keymap.set('v', '<leader>rg', ":'<,'>Rg<CR>", opts)
|
|||||||
|
|
||||||
-- Mapping to toggle checkboxes
|
-- Mapping to toggle checkboxes
|
||||||
vim.keymap.set('n', '<leader><CR>', ':CheckboxToggle<CR>', opts)
|
vim.keymap.set('n', '<leader><CR>', ':CheckboxToggle<CR>', opts)
|
||||||
|
|
||||||
|
-- Format whole file using internal algorithm
|
||||||
|
vim.keymap.set('n', '<leader>gw', function()
|
||||||
|
local view = vim.fn.winsaveview()
|
||||||
|
vim.cmd('normal! gggwG')
|
||||||
|
vim.fn.winrestview(view)
|
||||||
|
end, { desc = 'Format whole file with gw' })
|
||||||
|
|||||||
@@ -1,40 +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
|
|
||||||
|
|
||||||
-- Sort files in a sensible sequence
|
|
||||||
vim.g.netrw_sort_sequence = '[\\/]$,*'
|
|
||||||
|
|
||||||
-- 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
|
||||||
@@ -82,7 +91,7 @@ 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.foldtext = ''
|
||||||
vim.opt.fillchars = 'fold: '
|
vim.opt.fillchars = { fold = ' ' }
|
||||||
|
|
||||||
-- Enable all mouse features
|
-- Enable all mouse features
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = 'a'
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
# 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 function getIncludeGuardName()
|
||||||
@@ -13,38 +17,44 @@ local function getIncludeGuardName()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local snippets = {
|
local snippets = {
|
||||||
snip('#include', {
|
|
||||||
text('#include '),
|
|
||||||
insert(1, '<', { key = 'open' }),
|
|
||||||
insert(2, 'header'),
|
|
||||||
func(function(args)
|
|
||||||
if args[1][1] == '<' then
|
|
||||||
return '>'
|
|
||||||
else
|
|
||||||
return '"'
|
|
||||||
end
|
|
||||||
end, key('open')),
|
|
||||||
}),
|
|
||||||
|
|
||||||
snip('once', {
|
snippet('#include', {
|
||||||
|
text('#include '),
|
||||||
|
choice(1, {
|
||||||
|
snip(nil, { text('<'), restore(1, 'header'), text('>') }),
|
||||||
|
snip(nil, { text('"'), restore(1, 'header'), text('"') }),
|
||||||
|
}),
|
||||||
|
}, { stored = { ['header'] = insert(1, 'header') } }),
|
||||||
|
|
||||||
|
snippet('once', {
|
||||||
text('#ifndef '),
|
text('#ifndef '),
|
||||||
func(function(args)
|
func(function(opts)
|
||||||
return args[1][1]
|
return opts[1][1]
|
||||||
end, key('name')),
|
end, key('guard')),
|
||||||
text({ '', '#define ' }),
|
text({ '', '#define ' }),
|
||||||
insert(1, getIncludeGuardName(), { key = 'name' }),
|
dynamic(1, function()
|
||||||
-- FIXME: dynamic(1, function(_, _)
|
return snip(nil, {
|
||||||
-- return snip({}, {
|
insert(1, getIncludeGuardName(), { key = 'guard' }),
|
||||||
-- insert(1, getIncludeGuardName())
|
})
|
||||||
-- })
|
end),
|
||||||
-- end, { key = "name" }),
|
|
||||||
text({ '', '', '', }),
|
text({ '', '', '', }),
|
||||||
insert(0, ''),
|
insert(0, ''),
|
||||||
text({ '', '', '#endif // ' }),
|
text({ '', '', '#endif // ' }),
|
||||||
func(function(args)
|
func(function(opts)
|
||||||
return args[1][1]
|
return opts[1][1]
|
||||||
end, key('name')),
|
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}
|
||||||
|
|||||||
Reference in New Issue
Block a user