Compare commits

..

63 Commits

Author SHA1 Message Date
f59a288d59 Also don't highlight todo in mojo files 2026-01-05 11:51:13 +00:00
5def28d407 Reformat utilities.lua 2025-12-18 22:54:27 +00:00
2dec8af915 Disable signcolumn in dap-view-term filetype 2025-12-17 21:43:23 +00:00
27c50224f7 Enable dap-view auto toggle 2025-12-17 21:37:25 +00:00
39967dc120 Remove crashy console section from dap-view 2025-12-17 21:37:21 +00:00
bea244a4aa Add nvim-dap-disasm to view disassembly during debug 2025-12-17 21:18:29 +00:00
f08562558b Add DapViewToggle mapping 2025-12-17 21:17:19 +00:00
bc5ddb6dc7 Add restart & run_to_cursor dap mappings 2025-12-17 20:55:54 +00:00
f213c20d23 Update switchbuf for better nvim-dap usage 2025-12-16 19:31:43 +00:00
481c127583 Add console to nvim-dap-view's buffer 2025-12-16 19:19:55 +00:00
e0286197f8 Cleanup debugger plugin config 2025-12-16 19:19:08 +00:00
6fefe27f0e nvim-treesitter has breaking changes use master branch 2025-12-16 19:17:56 +00:00
82143dea23 Update switchbuf to include newtab 2025-12-16 19:14:30 +00:00
144d2b11cf Add nvim-dap & nvim-dap-view
Also don't enter insert mode when launching a debug session.
2025-12-16 18:24:50 +00:00
44199d81b4 Remove config = true from mdx pluing config 2025-12-16 18:24:04 +00:00
6401649361 Remove now default K mapping for LSP hover 2025-12-16 17:08:36 +00:00
ee385eb5da Cleanup completion plugins configuration 2025-12-16 17:08:36 +00:00
95d8c16621 Add pythonTodo to the list of naughty highlight groups 2025-12-04 14:57:16 +00:00
25209c7928 Remove broken mdx LSP 2025-11-21 14:10:03 +00:00
555644bc02 Add MDX LSP, filetype, and syntax highlighting 2025-11-21 12:08:01 +00:00
f51bbe1236 Add Hammerspoon Lua completions 2025-11-11 23:01:08 +00:00
b65d0ef36d Revert to the goated vim-unimpaired 2025-11-06 16:08:28 +00:00
65c394a681 Add vim-rhubarb for GitHub support in :GBrowse 2025-11-06 16:01:46 +00:00
4a03e07c59 Add marksman language server for markdown 2025-11-04 20:47:50 +00:00
3a8fb33ced Disable QuickFiles for now
This command can be invoked with `:Q` at the moment which happens
accidentally way more than I actually use this command.
2025-11-03 12:21:44 +00:00
3d736dca8a Switch to oil.nvim and drop netrw 2025-09-14 20:51:08 +01:00
745f6c408b Disable spell mode highlight groups if harper-ls installed 2025-08-27 11:04:23 +01:00
62f3061f48 Use tmux clipboard provider on Wayland
On Gnome Shell on Wayland `wl-copy` is automatically detected but using
it requires switching focus to the temporary invisible window it creates
as a workaround to the Wayland security feature that only the focused
application can interact with the clipboard. This does not happen when
`nvim` is run outside of `tmux`, so I can only assume that `tmux` is
seen to be the focused application, even though it's running inside
`kitty`, rather than `nvim` when running inside `tmux`.
2025-08-26 20:47:08 +01:00
8653c8b4cd Use same settings for gomod filetype as go 2025-08-26 20:40:28 +01:00
d261a49feb Add tinymist lsp 2025-08-19 23:09:43 +01:00
53ad787167 Ensure vim.lsp.hover has a rounded border 2025-08-19 17:04:05 +01:00
595c45724d Add most commonly used Doxygen comment snippets 2025-08-14 12:21:53 +01:00
4fc07f90d4 Fix typo 2025-08-13 15:06:46 +01:00
53d9b50e0b Reenable broadcast of extended LSP capabilities 2025-08-13 14:54:33 +01:00
4f38790589 Fix some lint in completsions.lua 2025-08-13 14:54:15 +01:00
00f87db692 Add harper-ls for spelling & grammer checking
This language server's default list of supported filetypes is
overridden, instead it is not automatically enabled but rather
(dis|en)abled when the `spell` setting is changed.
2025-08-13 14:28:33 +01:00
5a265839f9 Fix lsp setting overrides 2025-08-13 14:28:18 +01:00
0e2dcbc55b Show neovide border on macOS
This aligns with style of other windows.
2025-07-29 13:24:44 +01:00
7ff5ca4a6a Add support for local overrides in lua/local.lua
GUI's like Neovide require system specific settings for font size based
on monitor resolution, pixel density, and scaling. Add support for
loading `lua/local.lua` if it exists to enable overriding the default
for `vim.o.guifont` or similar options.
2025-07-29 11:38:46 +01:00
1529032ffb Add basic neovide config 2025-07-28 16:08:20 +01:00
3b79830ece Fix #include snippet for c/c++ 2025-07-23 14:39:58 +01:00
fad688fc15 Improve #include snippet for c/c++ 2025-07-23 14:15:39 +01:00
0471dd67c4 Add disabled dynamic node for C/C++ once snippet 2025-07-23 12:17:30 +01:00
94288ce806 Make LuaSnip mapping case consistent 2025-07-23 12:17:05 +01:00
516d3cbce7 Add LuaSnip choice mappings 2025-07-23 12:16:45 +01:00
a8c313b9cd Add live grep with args telescope mapping 2025-07-16 10:39:14 +01:00
Kenneth Benzie (Benie)
709b5b775f Switch back to virtualenv fallback of mason.nvim 2025-07-01 15:48:59 +01:00
d588b435ea Fix diagnostics mappings 2025-06-30 15:03:08 +01:00
fa06857e83 Add :QuickFiles command to add files to quickfix list 2025-06-19 13:29:23 +01:00
440fea18ee Be explicit about clangd when calling :LspRestart 2025-06-19 10:25:26 +01:00
d0b4e419e6 Use transparent foldtext feature
Removes an old workaround to show the first line of text in the fold
rather than a message.
2025-06-18 12:45:53 +01:00
1704b2f482 Switch back to williamboman/mason.nvim due to nvim v0.11.x 2025-06-06 10:50:37 +01:00
dc6aa82d73 Make netrw sort C/C++ header/source files beside each other 2025-06-03 12:25:01 +01:00
0b6fa260b9 Add <leader>gc mapping for :Telescope commands 2025-05-29 09:32:24 +01:00
bc201b3581 Add snippet for go error handling 2025-05-22 22:59:37 +01:00
fee0736439 Don't attempt to install gopls when go is missing 2025-05-20 15:48:29 +01:00
09534cf74c Add mapping to open telescope results in trouble 2025-05-20 15:25:11 +01:00
0f740ad8c0 Update trouble binding 2025-05-20 14:52:47 +01:00
18d5f5896b Add gopls language server 2025-04-27 22:08:00 +01:00
Kenneth Benzie (Benie)
946d1e7b4a Add :LStrip command to strip whitespace on the left 2025-04-03 16:27:43 +01:00
14709a12a7 Remove unicode from statusline
Some terminals use more characters than others for to display certain
unicode code points, this resulted the statusline to "leak" past the end
of the line causing characters at the next line to be highlighted
incorrectly.
2025-03-05 10:48:56 +00:00
830ace507e Add tablegen treesitter parser 2025-02-04 17:23:16 +00:00
96e912181c Use nvim_treesitter#indent() for Python 2025-01-25 20:33:06 +00:00
25 changed files with 375 additions and 159 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
lazy-lock.json
spell/*.spl
lua/local.lua

View File

@@ -0,0 +1 @@
vim.o.signcolumn = 'no'

6
after/ftplugin/gomod.lua Normal file
View 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
View File

@@ -0,0 +1,2 @@
-- Use treesitter for Python indenting since regex indenting is broken
vim.opt.indentexpr = 'nvim_treesitter#indent()'

View File

@@ -1,6 +1,15 @@
vim.g.mapleader = ' '
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'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ 'git', 'clone', '--filter=blob:none',

View File

@@ -36,7 +36,9 @@ local kanagawa = {
-- 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')

View File

@@ -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', -- 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 {
'neovim/nvim-lspconfig',
dependencies = {
@@ -72,14 +33,11 @@ return {
},
config = function()
local lspconfig_default_opts = {
-- Broadcast full client capabilities to language servers
capabilities = vim.tbl_deep_extend(
'force', vim.lsp.protocol.make_client_capabilities(),
require('cmp_nvim_lsp').default_capabilities()),
}
local capabilities = vim.tbl_deep_extend(
'force', vim.lsp.protocol.make_client_capabilities(),
require('cmp_nvim_lsp').default_capabilities())
local lspconfig_custom_opts = {
local server_opts = {
clangd = {
cmd = { 'clangd', '--completion-style=detailed' },
},
@@ -91,6 +49,12 @@ return {
disable = { 'missing-fields', },
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()
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({
automatic_installation = false,
ensure_installed = ensure_installed,
handlers = {
function(server_name)
local opts = vim.tbl_deep_extend("force",
lspconfig_default_opts, lspconfig_custom_opts[server_name] or {})
require('lspconfig')[server_name].setup(opts)
end,
},
ensure_installed = language_servers,
})
-- (Dis|en)able harper-ls when spell mode is (dis|en)enabled.
vim.api.nvim_create_autocmd("OptionSet", {
pattern = "spell",
callback = function()
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')
@@ -146,7 +175,7 @@ return {
},
formatting = {
format = function(entry, vim_item)
format = function(_, vim_item)
-- Set a limit to how wide the completion menu can be
local winwidth = vim.fn.winwidth(vim.api.nvim_get_current_win())
local menuwidth = math.min(winwidth / 2, 70)
@@ -164,7 +193,7 @@ return {
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({})
@@ -195,16 +224,10 @@ return {
-- Refactoring mappings
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
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
vim.keymap.set('n', '<leader>sf',
':ClangdSwitchSourceHeader<CR>', { silent = true })
@@ -220,5 +243,15 @@ return {
toggle_key_flip_floatwin_setting = true,
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
}

64
lua/plugins/debugger.lua Normal file
View 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,
}

View File

@@ -7,11 +7,15 @@ return {
config = function()
require('trouble').setup({})
local opts = { remap = false }
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '[d', function()
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>dq', function()
require('trouble').toggle()
require('trouble').toggle('diagnostics')
end, opts)
end
}

View File

@@ -1,5 +1,6 @@
return {
{ 'tpope/vim-fugitive', lazy = false },
{ 'tpope/vim-rhubarb', lazy = false },
{
'lewis6991/gitsigns.nvim',
config = function()

6
lua/plugins/mdx.lua Normal file
View File

@@ -0,0 +1,6 @@
return {
'davidmh/mdx.nvim',
dependencies = {
'nvim-treesitter/nvim-treesitter',
},
}

29
lua/plugins/oil.lua Normal file
View 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
}

View File

@@ -17,20 +17,20 @@ return {
luasnip.expand_or_jump()
end
end, { silent = true })
vim.keymap.set({ 'i', 's' }, '<C-K>', function()
vim.keymap.set({ 'i', 's' }, '<C-k>', function()
if luasnip.jumpable(-1) then
luasnip.jump(-1)
end
end, { silent = true })
-- vim.keymap.set('s', '<M-l>', function()
-- if luasnip.choice_active() then
-- luasnip.change_choice(1)
-- end
-- end, { silent = true })
-- vim.keymap.set('s', '<M-h>', function()
-- if luasnip.choice_active() then
-- luasnip.change_choice(-1)
-- end
-- 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
}

View File

@@ -3,6 +3,7 @@ return {
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-fzy-native.nvim',
'nvim-telescope/telescope-live-grep-args.nvim',
'nvim-tree/nvim-web-devicons',
'axkirillov/easypick.nvim',
'benfowler/telescope-luasnip.nvim',
@@ -16,11 +17,13 @@ return {
['<C-s>'] = 'select_horizontal',
['<C-h>'] = 'preview_scrolling_left',
['<C-l>'] = 'preview_scrolling_right',
['<C-q>'] = require("trouble.sources.telescope").open,
},
n = {
['<C-s>'] = 'select_horizontal',
['<C-h>'] = 'preview_scrolling_left',
['<C-l>'] = 'preview_scrolling_right',
['<C-q>'] = require("trouble.sources.telescope").open,
}
},
layout_config = {
@@ -29,6 +32,7 @@ return {
},
})
telescope.load_extension('fzy_native')
telescope.load_extension('live_grep_args')
telescope.load_extension('luasnip')
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.git_files, 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>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({
pickers = { },

View File

@@ -1,5 +1,6 @@
return {
'nvim-treesitter/nvim-treesitter',
branch = 'master',
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
{ 'nvim-treesitter/nvim-treesitter-context', opts = {} },
@@ -62,6 +63,7 @@ return {
'rst',
'ssh_config',
'strace',
'tablegen',
'tmux',
'toml',
'vim',

View File

@@ -33,13 +33,18 @@ local noice = {
return {
-- noice,
{ 'echasnovski/mini.comment', opts = { options = { ignore_blank_line = true } } },
{
'idanarye/nvim-impairative',
config = function()
require('impairative').setup({})
require('impairative.replicate-unimpaired')()
end},
'echasnovski/mini.comment',
opts = {
options = {
ignore_blank_line = true,
}
},
},
{
'tpope/vim-unimpaired',
lazy = false,
},
{ 'stevearc/dressing.nvim' },
{ 'kevinhwang91/nvim-bqf' },
}

View File

@@ -25,10 +25,17 @@ vim.api.nvim_create_autocmd('BufRead', {
-- Start terminals in insert mode
vim.api.nvim_create_autocmd('TermOpen', {
group = group, pattern = 'term://*',
callback = function()
group = group,
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()
end
end,
})
-- Automatically press enter when the terminal process exit successfully

View File

@@ -35,7 +35,7 @@ function build.set_dir(dirname)
-- 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')
vim.cmd('LspRestart clangd')
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
end)
end,
@@ -67,7 +67,7 @@ function build.set_dir(dirname)
-- 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')
vim.cmd('LspRestart clangd')
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
end)
end

View File

@@ -1,4 +1,4 @@
-- :RStrip 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)
local pos = vim.fn.getcurpos(vim.api.nvim_get_current_win())
local range = opts.line1 .. ',' .. opts.line2
@@ -7,6 +7,15 @@ vim.api.nvim_create_user_command('RStrip', function(opts)
vim.fn.setpos('.', pos)
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
vim.api.nvim_create_user_command('TabWidth', function(opts)
-- Set the tab width for the current filetype
@@ -134,7 +143,7 @@ vim.api.nvim_create_user_command('Rg', function(opts)
elseif #search == 0 then
search = vim.fn.expand('<cword>')
end
local grep_opts = { search = search}
local grep_opts = { search = search }
if opts.bang then
grep_opts['use_regex'] = true
end
@@ -196,3 +205,35 @@ end, { range = true })
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, {})

View File

@@ -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
})

View File

@@ -3,6 +3,12 @@ vim.g.loaded_node_provider = 0
vim.g.loaded_perl_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
vim.opt.sidescrolloff = 5
@@ -40,6 +46,9 @@ vim.opt.completeopt = 'menu'
-- Set window title to titlestring
vim.opt.title = true
-- Use rounded borders for floating windows
vim.o.winborder = 'rounded'
-- Don't show mode in command line
vim.opt.showmode = false
@@ -69,7 +78,7 @@ vim.opt.splitbelow = true
vim.opt.splitright = true
-- Use existing windows and tabs when jumping to errors
vim.opt.switchbuf = 'usetab'
vim.opt.switchbuf = 'usetab,uselast'
-- Automatically write changes to files
vim.opt.autowrite = true
@@ -81,13 +90,8 @@ vim.opt.joinspaces = false
vim.opt.foldlevel = 20
vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
vim.opt.foldtext = ''
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
vim.opt.mouse = 'a'

View File

@@ -60,7 +60,7 @@ local function get_mode()
end
-- Display cusor line/total and column
local position = '# %l/%L 󰠷 %2c '
local position = '# %l/%L:%2c '
-- Construct a statusline for special buffer types.
local function special(group, name, title)

View File

@@ -1,10 +1,14 @@
# C LuaSnip Snippets
-- C LuaSnip Snippets
local luasnip = require('luasnip')
local snip = luasnip.snippet
local snippet = luasnip.snippet
local text = luasnip.text_node
local insert = luasnip.insert_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 function getIncludeGuardName()
@@ -13,33 +17,44 @@ local function getIncludeGuardName()
end
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 '),
func(function(args)
return args[1][1]
end, key('name')),
func(function(opts)
return opts[1][1]
end, key('guard')),
text({ '', '#define ' }),
insert(1, getIncludeGuardName(), { key = 'name' }),
dynamic(1, function()
return snip(nil, {
insert(1, getIncludeGuardName(), { key = 'guard' }),
})
end),
text({ '', '', '', }),
insert(0, ''),
text({ '', '', '#endif // ' }),
func(function(args)
return args[1][1]
end, key('name')),
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

View File

@@ -4,3 +4,13 @@ snippet main
int main(${1:int argc, const char **argv}) {
$0
}
# Doxygen
snippet b
@brief ${0:desc}
snippet r
@return ${0:desc}
snippet rv
@retval ${1:val} ${0:desc}

View File

@@ -6,3 +6,8 @@ snippet main
func main() {
$0
}
snippet err
if err != nil {
$0
}