Compare commits
230 Commits
1568c56b0a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| c3fe8e033a | |||
| 0f4e759266 | |||
| b146971918 | |||
| a365bcb6b5 | |||
| 6affd78df7 | |||
| fcd5cfbd54 | |||
| 1996e631a3 | |||
| 0602390a2d | |||
| b0cfb31645 | |||
|
|
aba1664d09 | ||
|
|
9d5868304f | ||
| 56beb52997 | |||
| 48ad466bd3 | |||
| 4499dee3d6 | |||
| d75531ae3d | |||
|
|
9f0d9890fd | ||
| ccec3232b5 | |||
|
|
ed74a5909a | ||
| 5da8a3c2f6 | |||
| 75f9b205bd | |||
| f5ab986397 | |||
| 4ee7596ffc | |||
| 19d7ac86f2 | |||
| 3ff031990a | |||
| 9de31c4c59 | |||
| 500e786a70 | |||
| 94c332368f | |||
| eade51e5b9 | |||
| 61e4807f55 | |||
|
|
f717fd0468 | ||
| 5f2c45050c | |||
| 3e94d25caf | |||
|
|
06c8f8a751 | ||
| d4228e37b8 | |||
| e3d4651062 | |||
| 09c785eee9 | |||
| 63d2a3ffd3 | |||
| b5adbd3343 | |||
|
|
985df79d1a | ||
| c190e42da5 | |||
| 8d93cbdf57 | |||
| 1ba816fcf8 | |||
| 9d5b798385 | |||
| 727ebc81a8 | |||
| a3024efb61 | |||
| 0b9c2765d3 | |||
| a655cbe3d9 | |||
| 428cea9747 | |||
| ada48d79f4 | |||
| cfac2daaee | |||
| e08e933732 | |||
| c07896bfad | |||
| 4c8f6cbc8b | |||
| e5e2453efb | |||
| e11b4d54a2 | |||
| a4377b22ac | |||
| 6372e8f63c | |||
| 9a0f74eb97 | |||
| 0957a4853c | |||
| d90ae27edf | |||
| 6392327a28 | |||
| 959e9e5c52 | |||
| f254665710 | |||
| 253f6f306d | |||
| 0e427facfa | |||
| fd4cefb74b | |||
| 25885dd7c7 | |||
| 27f1e54777 | |||
| 046e33c614 | |||
| 6c59054a7a | |||
| 2098949e9c | |||
| eee4944354 | |||
| fe19c35f36 | |||
| 057c706699 | |||
| 93bea02a48 | |||
| 04b5e6e4fb | |||
| 4b4a1dbf38 | |||
| d92a312992 | |||
| ba4e6dc233 | |||
| 2784989570 | |||
| 53553c02f1 | |||
| b7b8053191 | |||
| 5198bc2e27 | |||
| 381d4e66cf | |||
| d7ac1f7213 | |||
| 5de0109989 | |||
| f95a8fb8e5 | |||
| 776fb1f204 | |||
| 61d734fbc0 | |||
| ab2d68579f | |||
| ef922c82f5 | |||
| 12f32b4d7d | |||
| 89bca77ef4 | |||
| 0bfd392b20 | |||
| 890fe6f928 | |||
| 1d1d922282 | |||
| 2f6b0ba33c | |||
| 7b17b794f6 | |||
| e64316e336 | |||
| 1a6203e911 | |||
| 7ae049437a | |||
| c0ab67d3a4 | |||
| a283ab973a | |||
| 3daca6d6d8 | |||
| 8add996ea0 | |||
| e8a420d99d | |||
| c8b6476a2b | |||
| 9f1c0228aa | |||
| 831ac41440 | |||
| 0c1328ead4 | |||
| 0feee4afbf | |||
| 83403a8416 | |||
| 50cc8ae3ab | |||
| 51c3bf1b9e | |||
| b9be6fba5a | |||
| c235fb88e1 | |||
| 772bf3a3c1 | |||
| 6317d02148 | |||
| 21502aadd6 | |||
| be5e7007c9 | |||
| 61dcbe301b | |||
| 2a6b777949 | |||
| f9825d9b69 | |||
| 355c4feecc | |||
| 6533a96ba0 | |||
| 6c0c906cb2 | |||
| 378c8b0be4 | |||
| 4072fd3ccf | |||
| 77452d989d | |||
| f93360d854 | |||
| fb2d661a0e | |||
| d774c2867f | |||
| 49af40c918 | |||
| f49f56d043 | |||
| 0d04a9812c | |||
| eae24ab24c | |||
| 6c941341ff | |||
| eaa63924e2 | |||
| 4644f7e6fa | |||
| 23ac458935 | |||
| 3353b099be | |||
| 0656de97fa | |||
| 573c548245 | |||
| bbe6c378fd | |||
| 51ae7955f7 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
lazy-lock.json
|
lazy-lock.json
|
||||||
|
spell/*.spl
|
||||||
|
lua/local.lua
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
require('build').create_commands()
|
local opts = { buffer = true, remap = false, silent = true }
|
||||||
|
vim.keymap.set('v', '0', ':PreProcIfWrap<CR>', opts)
|
||||||
|
|||||||
3
after/ftplugin/cmake.lua
Normal file
3
after/ftplugin/cmake.lua
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
vim.opt.commentstring = '#%s'
|
||||||
|
vim.opt.cinkeys = '0{,0},0),0],:,#1,!^F,o,O,e'
|
||||||
|
vim.opt.indentkeys = ':,!^F,o,O,e,=endif(,=ENDIF(,=endforeach(,=ENDFOREACH(,=endmacro(,=ENDMACRO(,=else(,=ELSE(,=elseif(,=ELSEIF(,=endwhile(,=ENDWHILE('
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
vim.bo.commentstring = '//%s'
|
vim.opt.commentstring = '//%s'
|
||||||
|
vim.opt.matchpairs:append('<:>')
|
||||||
|
|
||||||
require('build').create_commands()
|
local opts = { buffer = true, remap = false, silent = true }
|
||||||
|
-- vim.keymap.set('n', '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'
|
||||||
15
after/ftplugin/gitcommit.lua
Normal file
15
after/ftplugin/gitcommit.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
vim.opt.spell = true
|
||||||
|
vim.opt.textwidth = 72
|
||||||
|
|
||||||
|
-- Auto-wrap text using textwidth
|
||||||
|
vim.opt.formatoptions:append('t')
|
||||||
|
-- When formatting text, recognize numbered lists
|
||||||
|
vim.opt.formatoptions:append('n')
|
||||||
|
-- Allow formatting of comments with 'gq'
|
||||||
|
vim.opt.formatoptions:append('q')
|
||||||
|
-- Automatically insert the current comment leader after hitting 'o' or 'O' in
|
||||||
|
-- Normal mode
|
||||||
|
vim.opt.formatoptions:append('o')
|
||||||
|
|
||||||
|
-- A pattern that is used to recognize a list header
|
||||||
|
vim.opt.formatlistpat = "^\\s*\\d\\+\\.\\s\\+\\|^[-*+]\\s\\+"
|
||||||
5
after/ftplugin/gitconfig.lua
Normal file
5
after/ftplugin/gitconfig.lua
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
-- Setup tabs
|
||||||
|
vim.opt.expandtab = false
|
||||||
|
vim.opt.tabstop = 8
|
||||||
|
vim.opt.shiftwidth = 8
|
||||||
|
vim.opt.softtabstop = 8
|
||||||
6
after/ftplugin/go.lua
Normal file
6
after/ftplugin/go.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'
|
||||||
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'
|
||||||
4
after/ftplugin/help.lua
Normal file
4
after/ftplugin/help.lua
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
vim.opt.spell = false
|
||||||
|
vim.opt.number = false
|
||||||
|
vim.opt.relativenumber = false
|
||||||
|
vim.opt.signcolumn = 'no'
|
||||||
3
after/ftplugin/llvm.lua
Normal file
3
after/ftplugin/llvm.lua
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
-- Include % and . in keywords for easier navigation of ID's
|
||||||
|
vim.opt.iskeyword:append('%')
|
||||||
|
vim.opt.iskeyword:append('.')
|
||||||
1
after/ftplugin/make.lua
Normal file
1
after/ftplugin/make.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vim.opt.tabstop = 8
|
||||||
2
after/ftplugin/man.lua
Normal file
2
after/ftplugin/man.lua
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vim.opt.showbreak = ''
|
||||||
|
vim.opt.signcolumn = 'no'
|
||||||
1
after/ftplugin/opencl.lua
Normal file
1
after/ftplugin/opencl.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vim.opt.commentstring = '//%s'
|
||||||
20
after/ftplugin/python.lua
Normal file
20
after/ftplugin/python.lua
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
-- Use sane tab settings for Python
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
vim.opt.tabstop = 8
|
||||||
|
vim.opt.shiftwidth = 4
|
||||||
|
vim.opt.softtabstop = 4
|
||||||
|
|
||||||
|
vim.opt.textwidth = 0
|
||||||
|
|
||||||
|
-- Auto-wrap comments using textwidth
|
||||||
|
vim.opt.formatoptions:append('c')
|
||||||
|
-- Automatically insert the current comment leader after hitting <Enter> in
|
||||||
|
-- Insert mode
|
||||||
|
vim.opt.formatoptions:append('r')
|
||||||
|
-- Automatically insert the current comment leader after hitting 'o' or 'O' in
|
||||||
|
-- Normal mode.
|
||||||
|
vim.opt.formatoptions:append('o')
|
||||||
|
|
||||||
|
-- Set file encoding and format to sane values for Python
|
||||||
|
vim.opt.encoding = 'utf-8'
|
||||||
|
vim.opt.fileformat = 'unix'
|
||||||
1
after/ftplugin/requirements.lua
Normal file
1
after/ftplugin/requirements.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vim.opt.commentstring = '#%s'
|
||||||
1
after/ftplugin/tags.lua
Normal file
1
after/ftplugin/tags.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vim.opt.expandtab = false
|
||||||
2
after/ftplugin/text.lua
Normal file
2
after/ftplugin/text.lua
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
vim.opt.spell = true
|
||||||
|
vim.opt.textwidth = 80
|
||||||
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()'
|
||||||
34
init.lua
34
init.lua
@@ -1,24 +1,20 @@
|
|||||||
require('settings')
|
vim.g.mapleader = ' '
|
||||||
require('mappings')
|
vim.g.maplocalleader = ' '
|
||||||
require('netrw')
|
|
||||||
require('autocmds')
|
|
||||||
require('build')
|
|
||||||
|
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
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
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
vim.fn.system({
|
vim.fn.system({ 'git', 'clone', '--filter=blob:none',
|
||||||
"git",
|
'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath })
|
||||||
"clone",
|
|
||||||
"--filter=blob:none",
|
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
|
||||||
"--branch=stable", -- latest stable release
|
|
||||||
lazypath,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
require('lazy').setup('plugins', {
|
require('lazy').setup('plugins', { change_detection = { enabled = false } })
|
||||||
change_detection = {
|
|
||||||
enabled = false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
-- Create a group to namespace autocmds
|
|
||||||
local group = vim.api.nvim_create_augroup('benie', { clear = true })
|
|
||||||
|
|
||||||
-- Restore cursor position across sessions
|
|
||||||
-- https://github.com/neovim/neovim/issues/16339#issuecomment-1457394370
|
|
||||||
vim.api.nvim_create_autocmd('BufRead', {
|
|
||||||
group = group,
|
|
||||||
callback = function(opts)
|
|
||||||
vim.api.nvim_create_autocmd('BufWinEnter', {
|
|
||||||
once = true,
|
|
||||||
buffer = opts.buf,
|
|
||||||
callback = function()
|
|
||||||
local ft = vim.bo[opts.buf].filetype
|
|
||||||
local last_known_line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1]
|
|
||||||
if not (ft:match('commit') and ft:match('rebase'))
|
|
||||||
and last_known_line > 1
|
|
||||||
and last_known_line <= vim.api.nvim_buf_line_count(opts.buf)
|
|
||||||
then
|
|
||||||
vim.api.nvim_feedkeys([[g`"]], 'nx', false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
local build = {}
|
|
||||||
|
|
||||||
function build.dir(opts)
|
|
||||||
print(vim.inspect(opts))
|
|
||||||
local num_fargs = table.maxn(opts.fargs)
|
|
||||||
local dir = nil
|
|
||||||
|
|
||||||
if num_fargs == 0 then -- Find build directories
|
|
||||||
local dirs = build.list_dirs()
|
|
||||||
local num_dirs = table.maxn(dirs)
|
|
||||||
|
|
||||||
if num_dirs == 0 then
|
|
||||||
vim.cmd.echoerr('no build directories found')
|
|
||||||
elseif num_dirs == 1 then
|
|
||||||
-- One build directory found, use it
|
|
||||||
dir = dirs[1]
|
|
||||||
else
|
|
||||||
-- Multiple build directories found, select one
|
|
||||||
require("telescope.pickers.multi") {
|
|
||||||
prompt_title = "Select from the list",
|
|
||||||
results_title = "Options",
|
|
||||||
sorting_strategy = "ascending",
|
|
||||||
layout_strategy = "vertical",
|
|
||||||
winblend = 10,
|
|
||||||
border = true,
|
|
||||||
previewer = false, -- Set to true if you want a preview window
|
|
||||||
results = dir,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
if not dir then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO: Set build directory
|
|
||||||
-- TODO: Post-process compile_commands.json with compdb
|
|
||||||
end
|
|
||||||
|
|
||||||
function build.run(opts)
|
|
||||||
print(vim.inspect(opts))
|
|
||||||
end
|
|
||||||
|
|
||||||
function build.list_dirs()
|
|
||||||
local dirs = vim.fn.globpath('.', 'build*')
|
|
||||||
dirs = vim.fn.substitute(dirs, '\\.\\/', '', 'g')
|
|
||||||
return vim.fn.split(dirs)
|
|
||||||
end
|
|
||||||
|
|
||||||
function build.list_targets()
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function build.create_commands()
|
|
||||||
local buffer = vim.api.nvim_get_current_buf()
|
|
||||||
|
|
||||||
-- Create :BuildDir command
|
|
||||||
vim.api.nvim_buf_create_user_command(buffer, 'BuildDir', build.dir, {
|
|
||||||
bang = true, nargs = '?', complete = build.list_dirs,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Create :Build command
|
|
||||||
vim.api.nvim_buf_create_user_command(buffer, 'Build', build.run, {
|
|
||||||
bang = true, nargs = '*', complete = build.list_targets,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
return build
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
vim.g.mapleader = ' '
|
|
||||||
|
|
||||||
-- Quick write
|
|
||||||
vim.keymap.set('n', '<leader>w', ':w!<CR>', {noremap = true})
|
|
||||||
|
|
||||||
-- Treat long lines as line containing breaks
|
|
||||||
vim.keymap.set('n', 'j', 'gj', {noremap = true})
|
|
||||||
vim.keymap.set('n', 'k', 'gk', {noremap = true})
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>tn', ':tabnew<Space>', {noremap = true})
|
|
||||||
vim.keymap.set('n', '<leader>tc', ':tabclose<CR>', {noremap = true})
|
|
||||||
vim.keymap.set('n', '<leader>to', ':tabonly<CR>', {noremap = true})
|
|
||||||
vim.keymap.set('n', '<leader>tm', ':tabmove<Space>', {noremap = true})
|
|
||||||
|
|
||||||
-- Quickly access spelling menu
|
|
||||||
vim.keymap.set('i', '<C-s>', '<C-g>u<C-X>s', {noremap = true})
|
|
||||||
vim.keymap.set('n', '<C-s>', 'i<C-g>u<C-X>s', {noremap = true})
|
|
||||||
|
|
||||||
-- Clear search highlights
|
|
||||||
vim.keymap.set('n', '<leader><Space>', ':nohlsearch<CR>', {noremap = true})
|
|
||||||
|
|
||||||
-- Disable 'Q' from opening Ex mode
|
|
||||||
vim.keymap.set('n', 'Q', '<nop>', {noremap = true})
|
|
||||||
|
|
||||||
-- Yank and put mappings
|
|
||||||
-- TODO: This doesn't handle all use cases, only the basics. For example,
|
|
||||||
-- this doesn't handle a local tmux session with a remote nvim in a pane.
|
|
||||||
-- if tmux#isOption('set-clipboard', 'on') || $SSH_CONNECTION !=# ''
|
|
||||||
-- " When connected to a remote session the + selection register is not
|
|
||||||
-- " available and the unnamed register is used instead. Add mappings using the
|
|
||||||
-- " z register instead.
|
|
||||||
-- noremap <leader>y "zy
|
|
||||||
-- noremap <leader>Y "zY
|
|
||||||
-- " Enable OSC 52 copy on yank.
|
|
||||||
-- call osc52#autocmd()
|
|
||||||
-- else
|
|
||||||
-- System clipboard yank/put
|
|
||||||
vim.keymap.set('', '<leader>y', '"+y', { noremap = true })
|
|
||||||
vim.keymap.set('', '<leader>Y', '"+Y', { noremap = true })
|
|
||||||
vim.keymap.set('', '<leader>p', '"+p', { noremap = true })
|
|
||||||
vim.keymap.set('', '<leader>P', '"+P', { noremap = true })
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- Undo neovim's default mapping of Y to y$
|
|
||||||
vim.cmd('unmap Y')
|
|
||||||
|
|
||||||
-- Move visually selected blocks around
|
|
||||||
vim.keymap.set('v', 'J', ":move '>+1<CR>gv=gv'")
|
|
||||||
vim.keymap.set('v', 'K', ":move '<-2<CR>gv=gv'")
|
|
||||||
@@ -1,27 +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')
|
|
||||||
|
|
||||||
-- Invoke netrw on the directory containing the current file
|
|
||||||
vim.fn.execute(string.format("edit %s", vim.fn.expand('%:hp')))
|
|
||||||
|
|
||||||
-- In the netrw buffer, move the cursor to the first character of filename
|
|
||||||
local buffer = vim.api.nvim_get_current_buf()
|
|
||||||
local lines = vim.api.nvim_buf_get_lines(buffer, 0, -1, true)
|
|
||||||
for row, content in ipairs(lines) do
|
|
||||||
local column = string.find(content, filename)
|
|
||||||
if column then
|
|
||||||
vim.api.nvim_win_set_cursor(0, { row, column - 1 })
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
@@ -1,26 +1,48 @@
|
|||||||
return {
|
local kanagawa = {
|
||||||
|
|
||||||
-- 'rose-pine/neovim', name = 'rose-pine',
|
|
||||||
-- config = function()
|
|
||||||
-- require('rose-pine').setup({
|
|
||||||
-- styles = {
|
|
||||||
-- transparency = true,
|
|
||||||
-- },
|
|
||||||
-- -- TODO: Ideally only certain groups would have italics disabled
|
|
||||||
-- disable_italics = true,
|
|
||||||
-- })
|
|
||||||
-- vim.cmd('colorscheme rose-pine')
|
|
||||||
-- end
|
|
||||||
|
|
||||||
'rebelot/kanagawa.nvim',
|
'rebelot/kanagawa.nvim',
|
||||||
config = function()
|
config = function()
|
||||||
local kanagawa = require('kanagawa')
|
local kanagawa = require('kanagawa')
|
||||||
|
|
||||||
|
local dragon = {
|
||||||
|
ui = {
|
||||||
|
bg = '#080808',
|
||||||
|
bg_m3 = '#262626',
|
||||||
|
bg_gutter = '#121212',
|
||||||
|
bg_search = '#404000',
|
||||||
|
bg_visual = '#202020',
|
||||||
|
float = {
|
||||||
|
bg = '#080808',
|
||||||
|
bg_border = '#080808',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
kanagawa.setup({
|
kanagawa.setup({
|
||||||
commentStyle = { italic = false },
|
commentStyle = { italic = false },
|
||||||
keywordStyle = { italic = false},
|
keywordStyle = { italic = false },
|
||||||
-- TODO: make background darker
|
colors = { theme = { dragon = dragon } },
|
||||||
})
|
})
|
||||||
kanagawa.load('dragon')
|
kanagawa.load('dragon')
|
||||||
end
|
|
||||||
|
|
||||||
|
-- Override highlight groups
|
||||||
|
vim.cmd.highlight('TabLine', 'guifg=#949494', 'guibg=' .. dragon.ui.bg_m3)
|
||||||
|
vim.cmd.highlight('TabLineFill', 'guibg=' .. dragon.ui.bg_gutter)
|
||||||
|
vim.cmd.highlight('TabLineSel', 'guifg=#c8c093', '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('TreesitterContext', 'guibg=' .. dragon.ui.bg_gutter)
|
||||||
|
|
||||||
|
-- Don't lighlight TODO specially in comments
|
||||||
|
for _, todo_group in pairs({
|
||||||
|
'confTodo',
|
||||||
|
'ps1CommentTodo',
|
||||||
|
'pythonTodo',
|
||||||
|
'zshTodo',
|
||||||
|
}) do
|
||||||
|
vim.cmd.highlight('link ' .. todo_group .. ' Comment')
|
||||||
|
end
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return kanagawa
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
return {
|
|
||||||
'terrortylor/nvim-comment',
|
|
||||||
config = function()
|
|
||||||
require('nvim_comment').setup({
|
|
||||||
-- should comment out empty or whitespace only lines
|
|
||||||
comment_empty = false,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
}
|
|
||||||
@@ -1,71 +1,149 @@
|
|||||||
return {
|
return {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Language server management plugins
|
-- Language server management plugins
|
||||||
'williamboman/mason.nvim',
|
-- 'williamboman/mason.nvim',
|
||||||
|
'kbenzie/mason.nvim',
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason-lspconfig.nvim',
|
||||||
|
|
||||||
-- Completion plugins
|
-- Completion sources plugins
|
||||||
'hrsh7th/cmp-nvim-lsp', -- Source for built-in language server client
|
'hrsh7th/cmp-nvim-lsp', -- Source for built-in language server client
|
||||||
'hrsh7th/cmp-buffer', -- Source for buffer words
|
'saadparwaiz1/cmp_luasnip', -- Source for LuaSnip snippets
|
||||||
'hrsh7th/cmp-path', -- Source for filesystem paths
|
'hrsh7th/cmp-buffer', -- Source for buffer words
|
||||||
'hrsh7th/cmp-cmdline', -- Source for command-line
|
'hrsh7th/cmp-path', -- Source for filesystem paths
|
||||||
'hrsh7th/nvim-cmp', -- Completion engine combines and use the above
|
'petertriho/cmp-git', -- Source for Git/GitHub/GitLab
|
||||||
|
'hrsh7th/nvim-cmp', -- Completion engine combines and uses the above
|
||||||
|
|
||||||
|
-- Lua vim module support in lua language server
|
||||||
|
{ 'folke/lazydev.nvim', ft = 'lua', opts = {} },
|
||||||
|
-- Expose clangd extensions
|
||||||
|
'p00f/clangd_extensions.nvim',
|
||||||
|
|
||||||
-- LSP UI plugins
|
-- LSP UI plugins
|
||||||
'aznhe21/actions-preview.nvim',
|
'aznhe21/actions-preview.nvim',
|
||||||
|
'j-hui/fidget.nvim',
|
||||||
|
'nvim-tree/nvim-web-devicons',
|
||||||
|
'ray-x/lsp_signature.nvim',
|
||||||
|
|
||||||
-- Lue vim module support in lua language server
|
-- TODO: https://github.com/b0o/SchemaStore.nvim
|
||||||
'folke/neodev.nvim',
|
-- TODO: https://github.com/jmbuhr/otter.nvim
|
||||||
|
|
||||||
-- Snippet pluggins
|
|
||||||
'L3MON4D3/LuaSnip',
|
|
||||||
'saadparwaiz1/cmp_luasnip',
|
|
||||||
|
|
||||||
-- TODO: https://github.com/j-hui/fidget.nvim
|
|
||||||
|
|
||||||
-- TODO: https://github.com/nvimtools/none-ls.nvim
|
-- TODO: https://github.com/nvimtools/none-ls.nvim
|
||||||
|
|
||||||
-- TODO: https://github.com/mfussenegger/nvim-dap
|
-- TODO: https://github.com/mfussenegger/nvim-dap
|
||||||
-- TODO: https://github.com/rcarriga/nvim-dap-ui
|
-- TODO: https://github.com/rcarriga/nvim-dap-ui
|
||||||
},
|
},
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
require('mason').setup()
|
local capabilities = vim.tbl_deep_extend(
|
||||||
require('mason-lspconfig').setup({
|
'force', vim.lsp.protocol.make_client_capabilities(),
|
||||||
ensure_installed = {
|
require('cmp_nvim_lsp').default_capabilities())
|
||||||
'clangd',
|
|
||||||
'cmake',
|
|
||||||
'jsonls',
|
|
||||||
'lua_ls',
|
|
||||||
'lemminx',
|
|
||||||
'vimls',
|
|
||||||
'yamlls',
|
|
||||||
},
|
|
||||||
automatic_installation = false,
|
|
||||||
handlers = {
|
|
||||||
-- Default handler, sets up everything unless a custom language server
|
|
||||||
-- setup handler is defined below
|
|
||||||
function(server_name)
|
|
||||||
require('lspconfig')[server_name].setup({})
|
|
||||||
end,
|
|
||||||
|
|
||||||
['lua_ls'] = function()
|
local server_opts = {
|
||||||
require('neodev').setup()
|
clangd = {
|
||||||
local lspconfig = require('lspconfig')
|
cmd = { 'clangd', '--completion-style=detailed' },
|
||||||
lspconfig.lua_ls.setup({
|
},
|
||||||
settings = {
|
|
||||||
Lua = {
|
lua_ls = {
|
||||||
diagnostics = {
|
settings = {
|
||||||
disable = { 'missing-fields', },
|
Lua = {
|
||||||
globals = { 'vim', },
|
diagnostics = {
|
||||||
}
|
disable = { 'missing-fields', },
|
||||||
|
globals = { 'vim', },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
library = {
|
||||||
|
vim.fn.expand('~/.hammerspoon/Spoons'),
|
||||||
|
vim.fn.expand('~/.hammerspoon/Spoons/EmmyLua.spoon/annotations/'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
end
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pyright = {
|
||||||
|
settings = {
|
||||||
|
pyright = {
|
||||||
|
disableOrganizeImports = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
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({
|
||||||
|
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')
|
local cmp = require('cmp')
|
||||||
@@ -75,48 +153,73 @@ return {
|
|||||||
require('luasnip').lsp_expand(args.body)
|
require('luasnip').lsp_expand(args.body)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
-- Open completion menu/confirm completion
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
['<C-l>'] = cmp.mapping.confirm({ select = true }),
|
['<C-l>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
-- Select completion from menu
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
-- Scroll documentation of selected completion item
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
-- { name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
{ name = 'path' },
|
{ name = 'path' },
|
||||||
-- { name = 'cmdline' },
|
{ name = 'git' },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
formatting = {
|
||||||
|
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)
|
||||||
|
if menuwidth < 70 then
|
||||||
|
vim_item.menu = ''
|
||||||
|
vim_item.kind = ''
|
||||||
|
end
|
||||||
|
vim_item.abbr = string.sub(vim_item.abbr, 1, menuwidth)
|
||||||
|
return vim_item
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
|
||||||
|
preselect = 'None', -- Don't preselect completions suggested by source
|
||||||
})
|
})
|
||||||
|
require("cmp_git").setup({})
|
||||||
|
|
||||||
-- Disable displaying diagnostics as virtual text
|
-- Mappings created when LSP is attached to a buffer
|
||||||
vim.diagnostic.config({ virtual_text = false })
|
|
||||||
|
|
||||||
-- Diagnostic mappings
|
|
||||||
-- TODO: trouble.nvim mappings instead? https://youtu.be/MuUrCcvE-Yw?t=631
|
|
||||||
vim.keymap.set('n', '<C-n>', vim.diagnostic.goto_next, { noremap = true })
|
|
||||||
vim.keymap.set('n', '<C-p>', vim.diagnostic.goto_prev, { noremap = true })
|
|
||||||
vim.keymap.set('n', '<leader>sd', vim.diagnostic.open_float, { noremap = true })
|
|
||||||
|
|
||||||
-- LSP mappings created when attached to a buffer
|
|
||||||
local augroup = vim.api.nvim_create_augroup('lsp', { clear = true })
|
local augroup = vim.api.nvim_create_augroup('lsp', { clear = true })
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
pattern = '*',
|
pattern = '*',
|
||||||
group = augroup,
|
group = augroup,
|
||||||
callback = function(ev)
|
callback = function(event)
|
||||||
local opts = { noremap = true, buffer = ev.buf }
|
local opts = { noremap = true, buffer = event.buf }
|
||||||
|
|
||||||
-- Fixit mapping, or close enough, actually any code action
|
-- Fixit mapping, or close enough, actually any code action
|
||||||
vim.keymap.set('n', '<leader>fi',
|
vim.keymap.set('n', '<leader>fi',
|
||||||
require("actions-preview").code_actions, opts)
|
require('actions-preview').code_actions, opts)
|
||||||
|
|
||||||
-- Goto definition mapping
|
-- Goto mappings
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
local tb = require('telescope.builtin')
|
||||||
-- TODO: nnoremap <silent> <leader>gt <Plug>(coc-type-definition)
|
vim.keymap.set('n', 'gd', tb.lsp_definitions, opts)
|
||||||
-- TODO: nnoremap <silent> <leader>gu <Plug>(coc-references-used)
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set('n', 'gi', tb.lsp_implementations, opts)
|
||||||
-- Get references to symbol under cursor, store in quickfix window
|
vim.keymap.set('n', 'go', tb.lsp_type_definitions, opts)
|
||||||
vim.keymap.set('n', '<leader>gr', vim.lsp.buf.references, opts)
|
vim.keymap.set('n', 'gr', tb.lsp_references, opts)
|
||||||
|
vim.keymap.set('n', '<leader>ic', tb.lsp_incoming_calls, opts)
|
||||||
|
vim.keymap.set('n', '<leader>oc', tb.lsp_outgoing_calls, opts)
|
||||||
|
vim.keymap.set('n', '<leader>sd', tb.lsp_document_symbols, opts)
|
||||||
|
vim.keymap.set('n', '<leader>sw', tb.lsp_workspace_symbols, opts)
|
||||||
|
|
||||||
-- 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)
|
||||||
@@ -124,29 +227,31 @@ return {
|
|||||||
-- 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)
|
||||||
|
|
||||||
-- Help mappings
|
-- Switch file using clangd extension
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
-- TODO: limit this to only filetypes supported by clangd
|
||||||
vim.keymap.set('i', '<C-h>', vim.lsp.buf.signature_help, opts)
|
vim.keymap.set('n', '<leader>sf',
|
||||||
|
':ClangdSwitchSourceHeader<CR>', { silent = true })
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Snippet mappings
|
-- LSP UI plugins
|
||||||
local luasnip = require('luasnip')
|
require('fidget').setup({})
|
||||||
luasnip.setup({})
|
require('lsp_signature').setup({
|
||||||
vim.keymap.set({ 'i', 's' }, '<C-j>', function()
|
floating_window = true,
|
||||||
if luasnip.expand_or_jumpable() then
|
hint_enable = false,
|
||||||
luasnip.expand_or_jump()
|
toggle_key = '<C-h>',
|
||||||
end
|
toggle_key_flip_floatwin_setting = true,
|
||||||
end, { silent = true })
|
select_signature_key = '<C-l>',
|
||||||
vim.keymap.set({ 'i', 's' }, '<C-K>', function()
|
})
|
||||||
if luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
end
|
|
||||||
end, { silent = true })
|
|
||||||
|
|
||||||
-- Load snippets
|
-- When harper-ls is installed
|
||||||
local opts = { paths = vim.fn.stdpath('config') .. '/snippets' }
|
local mason_registry = require('mason-registry')
|
||||||
require('luasnip.loaders.from_snipmate').lazy_load(opts)
|
if mason_registry.is_installed('harper-ls') then
|
||||||
require('luasnip.loaders.from_lua').lazy_load(opts)
|
-- 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,
|
||||||
|
}
|
||||||
22
lua/plugins/diagnostics.lua
Normal file
22
lua/plugins/diagnostics.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
'folke/trouble.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-tree/nvim-web-devicons',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('trouble').setup({})
|
||||||
|
local opts = { remap = false }
|
||||||
|
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('diagnostics')
|
||||||
|
end, opts)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
{ 'tpope/vim-fugitive', lazy = true },
|
{ '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
|
||||||
|
}
|
||||||
36
lua/plugins/snippets.lua
Normal file
36
lua/plugins/snippets.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
return {
|
||||||
|
-- TODO: v0.10.0 might have builtins snippets?
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
build = 'make install_jsregexp',
|
||||||
|
config = function()
|
||||||
|
local luasnip = require('luasnip')
|
||||||
|
luasnip.setup({})
|
||||||
|
|
||||||
|
-- Load snippets
|
||||||
|
local opts = { paths = vim.fn.stdpath('config') .. '/snippets' }
|
||||||
|
require('luasnip.loaders.from_snipmate').lazy_load(opts)
|
||||||
|
require('luasnip.loaders.from_lua').lazy_load(opts)
|
||||||
|
|
||||||
|
-- Snippet keybindings
|
||||||
|
vim.keymap.set({ 'i', 's' }, '<C-j>', function()
|
||||||
|
if luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
vim.keymap.set({ 'i', 's' }, '<C-k>', function()
|
||||||
|
if luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-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
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
return {
|
|
||||||
'ojroques/nvim-hardline',
|
|
||||||
config = function()
|
|
||||||
require('hardline').setup({
|
|
||||||
sections = {
|
|
||||||
{ class = 'mode', item = require('hardline.parts.mode').get_item },
|
|
||||||
-- { class = 'high', item = require('hardline.parts.git').get_item, hide = 100 },
|
|
||||||
{ class = 'med', item = require('hardline.parts.filename').get_item },
|
|
||||||
'%<',
|
|
||||||
{ class = 'med', item = '%=' },
|
|
||||||
{ class = 'low', item = require('hardline.parts.wordcount').get_item, hide = 100 },
|
|
||||||
{ class = 'error', item = require('hardline.parts.lsp').get_error },
|
|
||||||
{ class = 'warning', item = require('hardline.parts.lsp').get_warning },
|
|
||||||
{ class = 'warning', item = require('hardline.parts.whitespace').get_item },
|
|
||||||
{ class = 'high', item = require('hardline.parts.filetype').get_item, hide = 60 },
|
|
||||||
{ class = 'mode', item = require('hardline.parts.line').get_item },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
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,8 +3,10 @@ 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',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local telescope = require('telescope')
|
local telescope = require('telescope')
|
||||||
@@ -15,24 +17,37 @@ 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 = {
|
||||||
|
height = 0.7,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
telescope.load_extension('fzy_native')
|
telescope.load_extension('fzy_native')
|
||||||
|
telescope.load_extension('live_grep_args')
|
||||||
|
telescope.load_extension('luasnip')
|
||||||
|
|
||||||
-- TODO: Add more mappings?
|
local builtin = require('telescope.builtin')
|
||||||
local opts = { noremap = true }
|
local opts = { noremap = true }
|
||||||
vim.keymap.set('n', '<leader>ff', ':Telescope find_files<CR>', opts)
|
vim.keymap.set('n', '<leader>gF', builtin.find_files, opts)
|
||||||
vim.keymap.set('n', '<leader>gf', ':Telescope git_files<CR>', opts)
|
vim.keymap.set('n', '<leader>gf', builtin.git_files, opts)
|
||||||
vim.keymap.set('n', '<leader>lg', ':Telescope live_grep<CR>', opts)
|
vim.keymap.set('n', '<leader>gg', builtin.live_grep, opts)
|
||||||
vim.keymap.set('n', '<leader>b', ':Telescope buffers<CR>', opts)
|
vim.keymap.set('n', '<leader>gG', telescope.extensions.live_grep_args.live_grep_args, opts)
|
||||||
vim.keymap.set('n', '<leader>ht', ':Telescope help_tags<CR>', 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>gl', builtin.current_buffer_fuzzy_find, opts)
|
||||||
|
vim.keymap.set('n', '<leader>gc', builtin.commands, opts)
|
||||||
|
|
||||||
|
require('easypick').setup({
|
||||||
|
pickers = { },
|
||||||
|
})
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,13 +1,22 @@
|
|||||||
return {
|
return {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
branch = 'master',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
|
{ 'nvim-treesitter/nvim-treesitter-context', opts = {} },
|
||||||
-- TODO: Fork this and add CMake support
|
-- TODO: Fork this and add CMake support
|
||||||
|
-- TODO: Add shell support (sh/bash/zsh if/for/while/etc)
|
||||||
'RRethy/nvim-treesitter-endwise',
|
'RRethy/nvim-treesitter-endwise',
|
||||||
},
|
},
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
config = function()
|
config = function()
|
||||||
require('nvim-treesitter').setup()
|
require('nvim-treesitter').setup()
|
||||||
local config = {
|
require('nvim-treesitter.configs').setup({
|
||||||
|
sync_install = false,
|
||||||
|
highlight = { enable = true },
|
||||||
|
indent = { enable = false },
|
||||||
|
|
||||||
|
-- List of languages that must be available
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
'asm',
|
'asm',
|
||||||
'bash',
|
'bash',
|
||||||
@@ -27,6 +36,7 @@ return {
|
|||||||
'gitattributes',
|
'gitattributes',
|
||||||
'gitignore',
|
'gitignore',
|
||||||
'glsl',
|
'glsl',
|
||||||
|
'go',
|
||||||
'gpg',
|
'gpg',
|
||||||
'hlsl',
|
'hlsl',
|
||||||
'html',
|
'html',
|
||||||
@@ -34,9 +44,12 @@ return {
|
|||||||
'javascript',
|
'javascript',
|
||||||
'jq',
|
'jq',
|
||||||
'json',
|
'json',
|
||||||
|
'julia',
|
||||||
'llvm',
|
'llvm',
|
||||||
'lua',
|
'lua',
|
||||||
'make',
|
'make',
|
||||||
|
'markdown',
|
||||||
|
'markdown_inline',
|
||||||
'meson',
|
'meson',
|
||||||
'ninja',
|
'ninja',
|
||||||
'objc',
|
'objc',
|
||||||
@@ -50,6 +63,7 @@ return {
|
|||||||
'rst',
|
'rst',
|
||||||
'ssh_config',
|
'ssh_config',
|
||||||
'strace',
|
'strace',
|
||||||
|
'tablegen',
|
||||||
'tmux',
|
'tmux',
|
||||||
'toml',
|
'toml',
|
||||||
'vim',
|
'vim',
|
||||||
@@ -57,17 +71,32 @@ return {
|
|||||||
'xml',
|
'xml',
|
||||||
'yaml',
|
'yaml',
|
||||||
},
|
},
|
||||||
sync_install = false,
|
|
||||||
highlight = {
|
-- After opening statements insert end statements
|
||||||
enable = true,
|
endwise = { enable = true },
|
||||||
|
|
||||||
|
-- Text objects using Tree-sitter groups
|
||||||
|
textobjects = {
|
||||||
|
select = {
|
||||||
|
enable = true,
|
||||||
|
lookahead = true,
|
||||||
|
-- include_surrounding_whitespace = true,
|
||||||
|
keymaps = {
|
||||||
|
-- Class text objects
|
||||||
|
['ac'] = '@class.outer',
|
||||||
|
['ic'] = '@class.inner',
|
||||||
|
-- Function text objects
|
||||||
|
['af'] = '@function.outer',
|
||||||
|
['if'] = '@function.inner',
|
||||||
|
-- Parameter/argument text objects
|
||||||
|
['a,'] = '@parameter.outer',
|
||||||
|
['i,'] = '@parameter.inner',
|
||||||
|
-- Comment text objects
|
||||||
|
['a/'] = '@comment.outer',
|
||||||
|
['i/'] = '@comment.inner',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
indent = {
|
})
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
endwise = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
require('nvim-treesitter.configs').setup(config)
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
40
lua/plugins/utilities.lua
Normal file
40
lua/plugins/utilities.lua
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
local noice = {
|
||||||
|
'folke/noice.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'MunifTanjim/nui.nvim',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('noice').setup({
|
||||||
|
cmdline = {
|
||||||
|
enable = true,
|
||||||
|
format = {
|
||||||
|
cmdline = { icon = ':', title = '' },
|
||||||
|
search_down = { icon = '/', title = '' },
|
||||||
|
search_up = { icon = '?', title = '' },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
messages = { enable = false },
|
||||||
|
popmenu = { enable = false },
|
||||||
|
notify = { enable = false },
|
||||||
|
lsp = {
|
||||||
|
progress = { enable = false },
|
||||||
|
hover = { enable = false },
|
||||||
|
signature = { enable = false },
|
||||||
|
message = { enable = false },
|
||||||
|
},
|
||||||
|
signature = { enabled = false },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Override highlight groups
|
||||||
|
vim.cmd.highlight('NoiceCmdlinePopupBorder', 'guibg=#080808')
|
||||||
|
vim.cmd.highlight('link', 'NoiceCmdlinePopupBorder', 'NoiceCmdlinePopupBorderSearch')
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
-- noice,
|
||||||
|
{ 'echasnovski/mini.comment', opts = { options = { ignore_blank_line = true } } },
|
||||||
|
{ 'tpope/vim-unimpaired', lazy = false },
|
||||||
|
{ 'stevearc/dressing.nvim' },
|
||||||
|
{ 'kevinhwang91/nvim-bqf' },
|
||||||
|
}
|
||||||
54
plugin/autocmds.lua
Normal file
54
plugin/autocmds.lua
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
-- Create a group to namespace autocmds
|
||||||
|
local group = vim.api.nvim_create_augroup('benie', { clear = true })
|
||||||
|
|
||||||
|
-- Restore cursor position across sessions
|
||||||
|
-- https://github.com/neovim/neovim/issues/16339#issuecomment-1457394370
|
||||||
|
vim.api.nvim_create_autocmd('BufRead', {
|
||||||
|
group = group,
|
||||||
|
callback = function(opts)
|
||||||
|
vim.api.nvim_create_autocmd('BufWinEnter', {
|
||||||
|
once = true,
|
||||||
|
buffer = opts.buf,
|
||||||
|
callback = function()
|
||||||
|
local ft = vim.bo[opts.buf].filetype
|
||||||
|
local last_known_line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1]
|
||||||
|
if not (ft:match('commit') and ft:match('rebase'))
|
||||||
|
and last_known_line > 1
|
||||||
|
and last_known_line <= vim.api.nvim_buf_line_count(opts.buf)
|
||||||
|
then
|
||||||
|
vim.api.nvim_feedkeys([[g`"]], 'nx', false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Start terminals in insert mode
|
||||||
|
vim.api.nvim_create_autocmd('TermOpen', {
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Automatically press enter when the terminal process exit successfully
|
||||||
|
vim.api.nvim_create_autocmd('TermClose', {
|
||||||
|
group = group,
|
||||||
|
pattern = 'term://*',
|
||||||
|
callback = function()
|
||||||
|
if vim.v.event.status == 0 then
|
||||||
|
-- Exit success, send enter to close the buffer
|
||||||
|
vim.api.nvim_input('<CR>')
|
||||||
|
else
|
||||||
|
-- Exit failure, enter normal mode for inspection
|
||||||
|
vim.api.nvim_input('<C-\\><C-n>')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
184
plugin/build.lua
Normal file
184
plugin/build.lua
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
local build = {}
|
||||||
|
|
||||||
|
build.dir = nil
|
||||||
|
|
||||||
|
local function echo(message, highlight)
|
||||||
|
vim.api.nvim_echo({ { message, highlight }, }, true, {})
|
||||||
|
end
|
||||||
|
|
||||||
|
function build.set_dir(dirname)
|
||||||
|
if not dirname then
|
||||||
|
build.select_dir()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local current_dir = vim.fn.getcwd()
|
||||||
|
local build_dir = current_dir .. '/' .. dirname
|
||||||
|
-- print(build_dir)
|
||||||
|
|
||||||
|
if vim.fn.isdirectory(build_dir) == 0 then
|
||||||
|
echo('directory does not exist: ' .. build_dir, 'Error')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
build.dir = build_dir
|
||||||
|
local compile_commands = current_dir .. '/compile_commands.json'
|
||||||
|
|
||||||
|
if vim.fn.executable('compdb') == 1 then
|
||||||
|
echo('Processing compile_commands.json with compdb ...', 'DiagnosticInfo')
|
||||||
|
-- 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
|
||||||
|
on_exit = 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,
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
-- Display the error message if there was one
|
||||||
|
if table.maxn(error) > 0 then
|
||||||
|
echo(vim.fn.join(error, '\n'), 'Error')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
function build.select_dir(callback)
|
||||||
|
local dirs = build.list_dirs()
|
||||||
|
callback = callback or nil
|
||||||
|
|
||||||
|
if table.maxn(dirs) == 1 then
|
||||||
|
build.set_dir(dirs[1])
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.exists(':Telescope') > 0 then
|
||||||
|
-- Create a Telescope picker with custom action.
|
||||||
|
require('telescope.pickers').new({}, {
|
||||||
|
prompt_title = 'Select build directory',
|
||||||
|
finder = require('telescope.finders').new_table({ results = dirs }),
|
||||||
|
sorter = require("telescope.config").values.generic_sorter({}),
|
||||||
|
attach_mappings = function(bufnr, map)
|
||||||
|
-- Override the default confirm action
|
||||||
|
map('i', '<CR>', function()
|
||||||
|
-- Get the select build directory
|
||||||
|
local state = require('telescope.actions.state')
|
||||||
|
build.set_dir(state.get_selected_entry().value)
|
||||||
|
-- Close the Telescope floating window
|
||||||
|
require('telescope.actions').close(bufnr)
|
||||||
|
-- Invoke the callback if provided
|
||||||
|
if callback then callback() end
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
layout_config = {
|
||||||
|
height = function(_, _, max_lines)
|
||||||
|
-- Limit the height based on the number of dirs
|
||||||
|
return math.min(max_lines, table.maxn(dirs) + 5)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}):find()
|
||||||
|
else
|
||||||
|
-- Prompt user to choose dir with to inputlist
|
||||||
|
local choices = {}
|
||||||
|
for index, choice in ipairs(dirs) do
|
||||||
|
table.insert(choices, tostring(index) .. ': ' .. choice)
|
||||||
|
end
|
||||||
|
local index = vim.fn.inputlist(choices)
|
||||||
|
build.dir = dirs[index]
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function build.run(args)
|
||||||
|
-- Check if build dir set, if not prompt user to select one
|
||||||
|
if not build.dir then
|
||||||
|
build.select_dir(function() build.run(args) end)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local command = nil
|
||||||
|
if vim.fn.filereadable(build.dir .. '/build.ninja') then
|
||||||
|
command = 'ninja'
|
||||||
|
elseif vim.fn.filereadable(build.dir .. '/Makefile') then
|
||||||
|
command = 'make'
|
||||||
|
else
|
||||||
|
echo('could not find build.ninja or Makefile in: ' .. build.dir)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
command = command .. ' -C ' .. build.dir .. ' ' .. vim.fn.join(args, ' ')
|
||||||
|
-- TODO: Figure out how to make the terminal window close on success
|
||||||
|
-- TODO: Running the terminal in a togglable floating window might be nice
|
||||||
|
vim.fn.execute('split | terminal ' .. command)
|
||||||
|
end
|
||||||
|
|
||||||
|
function build.list_dirs()
|
||||||
|
local dirs = vim.fn.globpath('.', 'build*')
|
||||||
|
dirs = vim.fn.substitute(dirs, '\\.\\/', '', 'g')
|
||||||
|
return vim.fn.split(dirs)
|
||||||
|
end
|
||||||
|
|
||||||
|
function build.list_targets()
|
||||||
|
local targets = {}
|
||||||
|
if not build.dir then
|
||||||
|
return targets
|
||||||
|
end
|
||||||
|
if vim.fn.filereadable(build.dir .. '/build.ninja') then
|
||||||
|
-- Query ninja for the list of targets
|
||||||
|
targets = vim.fn.systemlist('ninja -C ' .. build.dir .. ' -t targets')
|
||||||
|
for index, target in ipairs(targets) do
|
||||||
|
targets[index] = string.sub(target, 1, string.find(target, ':') - 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- TODO: Support make, it's much less straight forwards than ninja.
|
||||||
|
return targets
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create :BuildDir command
|
||||||
|
vim.api.nvim_create_user_command('BuildDir', function(opts)
|
||||||
|
build.set_dir(opts.fargs[1])
|
||||||
|
end, {
|
||||||
|
bang = true, nargs = '?', complete = build.list_dirs,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Create :Build command
|
||||||
|
vim.api.nvim_create_user_command('Build', function(opts)
|
||||||
|
build.run(opts.fargs)
|
||||||
|
end, {
|
||||||
|
bang = true, nargs = '*', complete = build.list_targets,
|
||||||
|
})
|
||||||
|
|
||||||
|
return build
|
||||||
239
plugin/commands.lua
Normal file
239
plugin/commands.lua
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
-- :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
|
||||||
|
vim.cmd.execute("'" .. range .. 's/\\s\\+$//e' .. "'")
|
||||||
|
vim.cmd.nohlsearch()
|
||||||
|
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
|
||||||
|
local width = tonumber(opts.args)
|
||||||
|
vim.opt.tabstop = width
|
||||||
|
vim.opt.shiftwidth = width
|
||||||
|
vim.opt.softtabstop = width
|
||||||
|
end, { nargs = 1 })
|
||||||
|
|
||||||
|
-- :Remove the file associated with the current buffer, bang to delete buffer
|
||||||
|
vim.api.nvim_create_user_command('Remove', function(opts)
|
||||||
|
local path = vim.fn.expand('%:p')
|
||||||
|
-- Using opts.bang in the callback can cause a SEGFAULT, instead use it
|
||||||
|
-- before invoking the async unlink to select which callback should be called
|
||||||
|
-- on completion.
|
||||||
|
local callback = nil
|
||||||
|
if opts.bang then
|
||||||
|
-- Invoked as :Remove! so also delete the buffer.
|
||||||
|
callback = function(err, success)
|
||||||
|
if success then
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.api.nvim_buf_delete(vim.api.nvim_get_current_buf(), {})
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Invoked as :Remove so don't delete the buffer.
|
||||||
|
callback = function(err, success)
|
||||||
|
if not success then
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- Actually remove the file using the selected callback.
|
||||||
|
vim.loop.fs_unlink(path, callback)
|
||||||
|
end, { bang = true })
|
||||||
|
|
||||||
|
-- :Move the file associated with the current buffer
|
||||||
|
vim.api.nvim_create_user_command('Move', function(opts)
|
||||||
|
local source = vim.fn.expand('%:p')
|
||||||
|
local dest = opts.args
|
||||||
|
if vim.fn.isdirectory(dest) ~= 0 then
|
||||||
|
dest = vim.fn.resolve(dest .. '/' .. vim.fn.expand('%:t'))
|
||||||
|
end
|
||||||
|
vim.loop.fs_rename(source, dest, function(err, success)
|
||||||
|
if success then
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.cmd.edit(dest)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, {
|
||||||
|
nargs = 1,
|
||||||
|
complete = 'file',
|
||||||
|
})
|
||||||
|
|
||||||
|
-- :Rename the file associated with current buffer
|
||||||
|
vim.api.nvim_create_user_command('Rename', function(opts)
|
||||||
|
local source = vim.fn.expand('%')
|
||||||
|
local dest = nil
|
||||||
|
local dir = vim.fn.expand('%:h')
|
||||||
|
if dir == '.' then
|
||||||
|
dest = opts.args
|
||||||
|
else
|
||||||
|
dest = vim.fn.resolve(dir .. '/' .. opts.args)
|
||||||
|
end
|
||||||
|
local buffer = vim.api.nvim_get_current_buf()
|
||||||
|
vim.loop.fs_rename(source, dest, function(err, success)
|
||||||
|
if not success then
|
||||||
|
error(err)
|
||||||
|
else
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.cmd.edit(dest)
|
||||||
|
vim.api.nvim_buf_delete(buffer, {})
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, {
|
||||||
|
nargs = 1,
|
||||||
|
complete = function()
|
||||||
|
return { vim.fn.expand('%:t') }
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- :Chmod change file mode bits
|
||||||
|
if vim.fn.executable('chmod') == 1 then
|
||||||
|
vim.api.nvim_create_user_command('Chmod', function(opts)
|
||||||
|
local file = vim.fn.expand('%:p')
|
||||||
|
vim.fn.system('chmod ' .. opts.args .. ' ' .. file)
|
||||||
|
end, { nargs = '+' })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- :Mkdir create a directory, bang to create intermediate directories
|
||||||
|
vim.api.nvim_create_user_command('Mkdir', function(opts)
|
||||||
|
local flags = nil
|
||||||
|
if opts.bang then
|
||||||
|
flags = 'p'
|
||||||
|
end
|
||||||
|
vim.fn.mkdir(opts.args, flags)
|
||||||
|
end, {
|
||||||
|
bang = true,
|
||||||
|
nargs = 1,
|
||||||
|
complete = 'file',
|
||||||
|
})
|
||||||
|
|
||||||
|
-- :Rg grep for the given string, word under the cursor, or visual selection
|
||||||
|
-- then fuzzy find the results. Bang to enable regex in given string.
|
||||||
|
vim.api.nvim_create_user_command('Rg', function(opts)
|
||||||
|
local search = opts.args
|
||||||
|
if opts.range == 2 then
|
||||||
|
local lines = vim.fn.getline(vim.fn.line("'<"), vim.fn.line("'>"))
|
||||||
|
local start_col = vim.fn.col("'<")
|
||||||
|
local end_col = vim.fn.col("'>")
|
||||||
|
if #lines == 1 then
|
||||||
|
lines[1] = string.sub(lines[1], start_col, end_col)
|
||||||
|
else
|
||||||
|
lines[1] = string.sub(lines[1], start_col)
|
||||||
|
lines[#lines] = string.sub(lines[#lines], 1, end_col)
|
||||||
|
end
|
||||||
|
search = table.concat(lines, "\n")
|
||||||
|
elseif #search == 0 then
|
||||||
|
search = vim.fn.expand('<cword>')
|
||||||
|
end
|
||||||
|
local grep_opts = { search = search }
|
||||||
|
if opts.bang then
|
||||||
|
grep_opts['use_regex'] = true
|
||||||
|
end
|
||||||
|
require('telescope.builtin').grep_string(grep_opts)
|
||||||
|
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)
|
||||||
|
local buffer = vim.api.nvim_get_current_buf()
|
||||||
|
vim.api.nvim_buf_set_lines(
|
||||||
|
buffer, opts.line2, opts.line2, true, { '#endif' })
|
||||||
|
vim.api.nvim_buf_set_lines(
|
||||||
|
buffer, opts.line1 - 1, opts.line1 - 1, true, { '#if 0' })
|
||||||
|
local window = vim.api.nvim_get_current_win()
|
||||||
|
vim.api.nvim_win_set_cursor(window, { opts.line1, 5 })
|
||||||
|
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, {})
|
||||||
19
plugin/filetype.lua
Normal file
19
plugin/filetype.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
vim.filetype.add({
|
||||||
|
extension = {
|
||||||
|
cl = 'opencl',
|
||||||
|
def = 'cpp',
|
||||||
|
ll = 'llvm',
|
||||||
|
md = 'markdown',
|
||||||
|
ronn = 'markdown',
|
||||||
|
td = 'tablegen',
|
||||||
|
test = 'llvm',
|
||||||
|
},
|
||||||
|
filename = {
|
||||||
|
['.enter'] = 'zsh',
|
||||||
|
['.exit'] = 'zsh',
|
||||||
|
['CMakeCache.txt'] = 'cmakecache',
|
||||||
|
['lit.cfg'] = 'python',
|
||||||
|
['lit.local.cfg'] = 'python',
|
||||||
|
['requirements.txt'] = 'requirements',
|
||||||
|
},
|
||||||
|
})
|
||||||
52
plugin/mappings.lua
Normal file
52
plugin/mappings.lua
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
local opts = { remap = false, silent = true }
|
||||||
|
|
||||||
|
-- Quick write
|
||||||
|
vim.keymap.set('n', '<leader>w', ':w!<CR>', opts)
|
||||||
|
|
||||||
|
-- Treat long lines as line containing breaks
|
||||||
|
vim.keymap.set('n', 'j', 'gj', opts)
|
||||||
|
vim.keymap.set('n', 'k', 'gk', opts)
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>tn', ':tabnew<Space>', { remap = false })
|
||||||
|
vim.keymap.set('n', '<leader>tm', ':tabmove<Space>', { remap = false })
|
||||||
|
vim.keymap.set('n', '<leader>tc', ':tabclose<CR>', opts)
|
||||||
|
vim.keymap.set('n', '<leader>to', ':tabonly<CR>', opts)
|
||||||
|
|
||||||
|
-- Quickly access spelling menu
|
||||||
|
vim.keymap.set('i', '<C-s>', '<C-g>u<C-X>s', opts)
|
||||||
|
vim.keymap.set('n', '<C-s>', 'i<C-g>u<C-X>s', opts)
|
||||||
|
|
||||||
|
-- Clear search highlights
|
||||||
|
vim.keymap.set('n', '<leader><Space>', ':nohlsearch<CR>', opts)
|
||||||
|
|
||||||
|
-- Disable 'Q' from opening Ex mode
|
||||||
|
vim.keymap.set('n', 'Q', '<nop>', opts)
|
||||||
|
|
||||||
|
-- System clipboard yank/put
|
||||||
|
vim.keymap.set('', '<leader>y', '"+y', opts)
|
||||||
|
vim.keymap.set('', '<leader>Y', '"+Y', opts)
|
||||||
|
vim.keymap.set('', '<leader>p', '"+p', opts)
|
||||||
|
vim.keymap.set('', '<leader>P', '"+P', opts)
|
||||||
|
|
||||||
|
-- Undo neovim's default mapping of Y to y$
|
||||||
|
vim.cmd.unmap('Y')
|
||||||
|
|
||||||
|
-- Make nvim :terminal more like vim :terminal
|
||||||
|
vim.keymap.set('t', '<C-w>N', '<C-\\><C-n>', opts)
|
||||||
|
|
||||||
|
-- Mappings to make navigating :Termdebug
|
||||||
|
vim.keymap.set('n', '<C-w><C-g>', ':Gdb<CR>:startinsert<CR>', opts)
|
||||||
|
vim.keymap.set('n', '<C-w><C-e>', ':Program<CR>', opts)
|
||||||
|
vim.keymap.set('n', '<C-w><C-s>', ':Source<CR>', opts)
|
||||||
|
vim.keymap.set('n', '<C-w><C-a>', ':Asm<CR>', opts)
|
||||||
|
vim.keymap.set('t', '<C-w><C-g>', '<C-\\><C-n>:Gdb<CR>:startinsert<CR>', opts)
|
||||||
|
vim.keymap.set('t', '<C-w><C-e>', '<C-\\><C-n>:Program<CR>', opts)
|
||||||
|
vim.keymap.set('t', '<C-w><C-s>', '<C-\\><C-n>:Source<CR>', opts)
|
||||||
|
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
|
||||||
|
vim.keymap.set('n', '<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)
|
||||||
@@ -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
|
||||||
@@ -77,6 +86,13 @@ vim.opt.autowrite = true
|
|||||||
-- Don't add 2 spaces after end of sentence
|
-- Don't add 2 spaces after end of sentence
|
||||||
vim.opt.joinspaces = false
|
vim.opt.joinspaces = false
|
||||||
|
|
||||||
|
-- Set fold level to something high
|
||||||
|
vim.opt.foldlevel = 20
|
||||||
|
vim.opt.foldmethod = 'expr'
|
||||||
|
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||||
|
vim.opt.foldtext = ''
|
||||||
|
vim.opt.fillchars = 'fold: '
|
||||||
|
|
||||||
-- Enable all mouse features
|
-- Enable all mouse features
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = 'a'
|
||||||
|
|
||||||
@@ -105,3 +121,24 @@ vim.opt.smartindent = true
|
|||||||
-- (0,W4 - indent inside unclosed parenthesis
|
-- (0,W4 - indent inside unclosed parenthesis
|
||||||
-- i2 - indent C++ class base declarations and constructor initializers
|
-- i2 - indent C++ class base declarations and constructor initializers
|
||||||
vim.opt.cinoptions = 'N-sE-sg1h1l1(0,W4i2'
|
vim.opt.cinoptions = 'N-sE-sg1h1l1(0,W4i2'
|
||||||
|
|
||||||
|
-- Avoid prompts and short/remove messages
|
||||||
|
-- f use "(3 of 5)" instead of "(file 3 of 5)"
|
||||||
|
-- i use "[noeol]" instead of "[Incomplete last line]"
|
||||||
|
-- l use "999L, 888B" instead of "999 lines, 888 bytes"
|
||||||
|
-- n use "[New]" instead of "[New File]"
|
||||||
|
-- x use "[dos]" instead of "[dos format]", "[unix]" instead of
|
||||||
|
-- "[unix format]" and "[mac]" instead of "[mac format]"
|
||||||
|
-- o overwrite message for writing a file with subsequent message for reading
|
||||||
|
-- a file (useful for ":wn" or when 'autowrite' on)
|
||||||
|
-- O message for reading a file overwrites any previous message; also for
|
||||||
|
-- quickfix message (e.g., ":cn")
|
||||||
|
-- t truncate file message at the start if it is too long to fit on the
|
||||||
|
-- command-line, "<" will appear in the left most column; ignored in
|
||||||
|
-- Ex mode
|
||||||
|
-- T truncate other messages in the middle if they are too long to fit on
|
||||||
|
-- the command line; "..." will appear in the middle; ignored in Ex mode
|
||||||
|
-- I don't give the intro message when starting Vim, see :intro
|
||||||
|
-- F don't give the file info when editing a file, like `:silent` was used
|
||||||
|
-- for the command
|
||||||
|
vim.opt.shortmess = 'filnxoOtTIF'
|
||||||
185
plugin/statusline.lua
Normal file
185
plugin/statusline.lua
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
local statusline = {}
|
||||||
|
|
||||||
|
local theme = {
|
||||||
|
light_green = { fg = '#262626', bg = '#59946f' },
|
||||||
|
light_blue = { fg = '#262626', bg = '#5c91bf' },
|
||||||
|
light_orange = { fg = '#262626', bg = '#b6927b' },
|
||||||
|
light_red = { fg = '#262626', bg = '#e46876' },
|
||||||
|
light_grey = { fg = '#262626', bg = '#808080' },
|
||||||
|
light_violet = { fg = '#262626', bg = '#957fb8' },
|
||||||
|
dark_white = { fg = '#ffffff', bg = '#121212' },
|
||||||
|
dark_yellow = { fg = '#c4b28a', bg = '#121212' },
|
||||||
|
dark_grey = { fg = '#808080', bg = '#121212' },
|
||||||
|
}
|
||||||
|
|
||||||
|
local modes = {}
|
||||||
|
modes[110] = { name = 'Normal', color = 'light_green' }
|
||||||
|
modes[105] = { name = 'Insert', color = 'light_blue' }
|
||||||
|
modes[99] = { name = 'Command', color = 'light_green' }
|
||||||
|
modes[118] = { name = 'Visual', color = 'light_violet' }
|
||||||
|
modes[86] = { name = 'V-Line', color = 'light_violet' }
|
||||||
|
modes[22] = { name = 'V-Block', color = 'light_violet' }
|
||||||
|
modes[82] = { name = 'Replace', color = 'light_red' }
|
||||||
|
modes[115] = { name = 'Select', color = 'light_orange' }
|
||||||
|
modes[83] = { name = 'S-Line', color = 'light_orange' }
|
||||||
|
modes[19] = { name = 'S-Block', color = 'light_orange' }
|
||||||
|
modes[116] = { name = 'Terminal', color = 'light_blue' }
|
||||||
|
modes[33] = { name = 'Shell', color = 'light_grey' }
|
||||||
|
|
||||||
|
local function highlight(group, color, attrs)
|
||||||
|
local args = { group, 'guifg=' .. color.fg, 'guibg=' .. color.bg }
|
||||||
|
if attrs then
|
||||||
|
table.insert(args, 'gui=' .. attrs)
|
||||||
|
end
|
||||||
|
vim.cmd.highlight(args)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- StatusLineLight is shows the mode and cursor information, it is dynamically
|
||||||
|
-- changed by statusline#mode(), give it a default.
|
||||||
|
highlight('StatusLineLight', theme.light_grey)
|
||||||
|
-- StatusLineDusk is shows additional information which is not always present,
|
||||||
|
-- give it a muted color.
|
||||||
|
highlight('StatusLineDusk', theme.light_grey, 'bold')
|
||||||
|
-- StatusLineDark shows the filename and filetype and takes up most of the
|
||||||
|
-- statusline, give it a dark background.
|
||||||
|
highlight('StatusLineDark', theme.dark_white)
|
||||||
|
-- StatusLineChange shows changes in the file by changing the colour of the
|
||||||
|
-- filename, give if a dark background.
|
||||||
|
highlight('StatusLineChange', theme.dark_yellow)
|
||||||
|
-- StatusLineFade shows the status of completion engines but using colors which
|
||||||
|
-- fade into the background to avoid grabbing attention.
|
||||||
|
highlight('StatusLineDuskFade', theme.dark_grey)
|
||||||
|
|
||||||
|
-- Get statusline mode and update StatusLineLight.
|
||||||
|
local function get_mode()
|
||||||
|
-- Map modes to a human readable name and a color.
|
||||||
|
local current_mode = modes[vim.fn.char2nr(vim.fn.mode())]
|
||||||
|
-- Update the StatusLineLight color.
|
||||||
|
highlight('StatusLineLight', theme[current_mode.color], 'bold')
|
||||||
|
return current_mode.name
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Display cusor line/total and column
|
||||||
|
local position = '# %l/%L:%2c '
|
||||||
|
|
||||||
|
-- Construct a statusline for special buffer types.
|
||||||
|
local function special(group, name, title)
|
||||||
|
-- Display current mode with dynamic highlights.
|
||||||
|
local line = '%#' .. group .. '# ' .. name .. ' '
|
||||||
|
-- Display filename with dark highlights.
|
||||||
|
line = line .. '%#StatusLineDark# ' .. title
|
||||||
|
-- Display current/total lines and column with dynamic highlights.
|
||||||
|
line = line .. '%=' .. '%#' .. group .. position
|
||||||
|
-- Combine the elements into a single string to be evaluated.
|
||||||
|
return line
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Construct a statusline for generic buffer types.
|
||||||
|
local function generic(group, name)
|
||||||
|
-- Display current mode with dynamic highlights.
|
||||||
|
local line = '%#' .. group .. '# ' .. name .. ' '
|
||||||
|
-- Display spell or paste if set with dusk highlights in a group to swallow
|
||||||
|
-- the spaces when empty.
|
||||||
|
line = line .. '%#StatusLineDusk#%( ' .. '%{&spell ? "Spell " : ""}' ..
|
||||||
|
'%{&paste ? "Paste " : ""}' .. '%)'
|
||||||
|
-- Display filename with dark or changed highlights.
|
||||||
|
if vim.o.modified then
|
||||||
|
line = line .. '%#StatusLineChange#'
|
||||||
|
else
|
||||||
|
line = line .. '%#StatusLineDark#'
|
||||||
|
end
|
||||||
|
line = line .. ' %<%f'
|
||||||
|
-- Display readonly and nomodifiable if set.
|
||||||
|
line = line
|
||||||
|
.. '%#StatusLineDark#'
|
||||||
|
.. '%{&readonly ? " 🔒" : ""}'
|
||||||
|
.. '%{&modifiable ? "" : " ⛔"}'
|
||||||
|
-- Display filetype if set.
|
||||||
|
line = line .. '%=' .. '%#StatusLineDark# %{&filetype} '
|
||||||
|
-- Display fileencoding if not utf-8 and fileformat if not unix with dusk
|
||||||
|
-- highlights in a group to swallow spaces when empty.
|
||||||
|
line = line .. '%#StatusLineDusk#%( ' ..
|
||||||
|
'%{&fileencoding ==# "utf-8" ? "" : &fileencoding}' ..
|
||||||
|
'%{&fileformat ==# "unix" ? "" : "[".&fileformat."]"}' .. ' %)'
|
||||||
|
-- Display current/total lines and column with dynamic highlights.
|
||||||
|
line = line .. '%#' .. group .. position
|
||||||
|
-- Combine the elements into a single string to be evaluated.
|
||||||
|
return line
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Define active statusline, this statusline is dynamic with StatusLineLight
|
||||||
|
-- being updated based on the current mode and only used for current buffer.
|
||||||
|
function _G.statusline_active()
|
||||||
|
local mode = get_mode()
|
||||||
|
if vim.o.buftype == 'help' then
|
||||||
|
if mode == 'Normal' then mode = 'Help' end
|
||||||
|
return special('StatusLineDusk', 'Help', '%F')
|
||||||
|
elseif vim.o.buftype == 'quickfix' then
|
||||||
|
-- Quickfix list and location list have the same buftype, the window has a
|
||||||
|
-- loclist flag, query the window info.
|
||||||
|
local info = vim.fn.getwininfo(vim.fn.win_getid())[1]
|
||||||
|
if mode == 'Normal' then
|
||||||
|
if info.loclist == 1 then
|
||||||
|
mode = 'Location'
|
||||||
|
else
|
||||||
|
mode = 'Quickfix'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local title = info.variables.quickfix_title
|
||||||
|
return special('StatusLineLight', mode, title)
|
||||||
|
elseif vim.o.buftype == 'terminal' then
|
||||||
|
return special('StatusLineLight', 'Terminal', '%f')
|
||||||
|
elseif vim.o.previewwindow then
|
||||||
|
if mode == 'Normal' then mode = 'Preview' end
|
||||||
|
return generic('StatusLineLight', mode)
|
||||||
|
elseif vim.o.filetype == 'man' then
|
||||||
|
return special('StatusLineDusk', 'Manual', '%f')
|
||||||
|
end
|
||||||
|
return generic('StatusLineLight', mode)
|
||||||
|
end
|
||||||
|
|
||||||
|
function _G.statusline_inactive()
|
||||||
|
local mode = modes[vim.fn.char2nr(vim.fn.mode())].name
|
||||||
|
local line = ''
|
||||||
|
if vim.o.buftype == 'help' then
|
||||||
|
line = special('StatusLineDusk', 'Help', '%F')
|
||||||
|
elseif vim.o.buftype == 'quickfix' then
|
||||||
|
-- Quickfix list and location list have the same buftype, the window has a
|
||||||
|
-- loclist flag, query the window info.
|
||||||
|
local info = vim.fn.getwininfo(vim.fn.win_getid())[1]
|
||||||
|
if info['loclist'] then mode = 'Location' else mode = 'Quickfix' end
|
||||||
|
line = special('StatusLineDusk', mode, info.variables.quickfix_title)
|
||||||
|
elseif vim.o.buftype == 'terminal' then
|
||||||
|
line = special('StatusLineDusk', 'Terminal', '%f')
|
||||||
|
elseif vim.o.previewwindow then
|
||||||
|
line = generic('StatusLineDusk', 'Preview')
|
||||||
|
elseif vim.o.filetype == 'man' then
|
||||||
|
line = special('StatusLineDusk', 'Manual', '%f')
|
||||||
|
else
|
||||||
|
line = generic('StatusLineDusk', 'Idle')
|
||||||
|
end
|
||||||
|
return line
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Setup autocmds to set the statusline per buffer.
|
||||||
|
local group = vim.api.nvim_create_augroup('statusline', { clear = true })
|
||||||
|
-- Dynamically update the current buffer mode and color changes using %! to
|
||||||
|
-- call a function which is always evaluated on statusline update.
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufEnter', 'WinEnter', 'BufWinEnter' }, {
|
||||||
|
pattern = '*',
|
||||||
|
group = group,
|
||||||
|
callback = function()
|
||||||
|
vim.cmd.setlocal("statusline=%{%v:lua.statusline_active()%}")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Statically set the statusline when leaving the buffer.
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufLeave', 'WinLeave' }, {
|
||||||
|
pattern = '*',
|
||||||
|
group = group,
|
||||||
|
callback = function()
|
||||||
|
vim.cmd.setlocal("statusline=%{%v:lua.statusline_inactive()%}")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
return statusline
|
||||||
22
plugin/ui.lua
Normal file
22
plugin/ui.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
-- Customise LSP UI
|
||||||
|
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
||||||
|
vim.lsp.handlers.hover, {
|
||||||
|
border = 'rounded',
|
||||||
|
title = 'Hover',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
||||||
|
vim.lsp.handlers.signature_help, {
|
||||||
|
border = 'rounded',
|
||||||
|
title = 'Signature Help',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Customise diagnostic UI
|
||||||
|
vim.diagnostic.config({
|
||||||
|
float = {
|
||||||
|
border = 'rounded',
|
||||||
|
title = 'Diagnostics',
|
||||||
|
},
|
||||||
|
virtual_text = false,
|
||||||
|
})
|
||||||
@@ -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,7 +1,19 @@
|
|||||||
# Global SnipMate snippets
|
# Global SnipMate snippets
|
||||||
|
|
||||||
|
snippet joy
|
||||||
|
(◦U ◡ U◦)
|
||||||
|
|
||||||
snippet shrug
|
snippet shrug
|
||||||
¯\_(ツ)_/¯
|
¯\_(ツ)_/¯
|
||||||
|
|
||||||
|
snippet confuse
|
||||||
|
(ノ*・_・)ノ
|
||||||
|
|
||||||
snippet tableflip
|
snippet tableflip
|
||||||
(╯°▪°)╯︵┻━┻
|
(╯°▪°)╯︵┻━┻
|
||||||
|
|
||||||
|
snippet cry
|
||||||
|
(ㅠ﹏ㅠ)
|
||||||
|
|
||||||
|
snippet think
|
||||||
|
(╭ರ_•́)
|
||||||
|
|||||||
60
snippets/c.lua
Normal file
60
snippets/c.lua
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
-- C LuaSnip Snippets
|
||||||
|
|
||||||
|
local luasnip = require('luasnip')
|
||||||
|
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()
|
||||||
|
local filename = vim.fn.expand('%'):gsub('[^%w_]', '_'):upper()
|
||||||
|
return filename .. '_INCLUDED'
|
||||||
|
end
|
||||||
|
|
||||||
|
local snippets = {
|
||||||
|
|
||||||
|
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(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
|
||||||
16
snippets/c.snippets
Normal file
16
snippets/c.snippets
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# C SnipMate snippets
|
||||||
|
|
||||||
|
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}
|
||||||
48
snippets/cpp.lua
Normal file
48
snippets/cpp.lua
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
-- C++ LuaSnip Snippets
|
||||||
|
|
||||||
|
local luasnip = require('luasnip')
|
||||||
|
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
|
||||||
@@ -1,2 +1,20 @@
|
|||||||
snippet array
|
# C++ SnipMate snippets
|
||||||
std::array<${1:T}, ${2:N}> ${3:array};${4}
|
|
||||||
|
extends c
|
||||||
|
|
||||||
|
snippet namespace
|
||||||
|
namespace ${1} {
|
||||||
|
$0
|
||||||
|
} // namespace ${1}
|
||||||
|
|
||||||
|
snippet const_cast
|
||||||
|
const_cast<$1>($2)$0
|
||||||
|
|
||||||
|
snippet static_cast
|
||||||
|
static_cast<$1>($2)$0
|
||||||
|
|
||||||
|
snippet dynamic_cast
|
||||||
|
dynamic_cast<$1>($2)$0
|
||||||
|
|
||||||
|
snippet reinterpret_cast
|
||||||
|
reinterpret_cast<$1>($2)$0
|
||||||
|
|||||||
59
snippets/go.lua
Normal file
59
snippets/go.lua
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Go LuaSnip Snippets
|
||||||
|
|
||||||
|
local luasnip = require('luasnip')
|
||||||
|
local snip = luasnip.snippet
|
||||||
|
local text = luasnip.text_node
|
||||||
|
local ins = luasnip.insert_node
|
||||||
|
local func = luasnip.function_node
|
||||||
|
local node = luasnip.snippet_node
|
||||||
|
local key = require("luasnip.nodes.key_indexer").new_key
|
||||||
|
|
||||||
|
local function short_name(name)
|
||||||
|
local short = string.lower(string.sub(name, 1, 1))
|
||||||
|
for i = 2, #name do
|
||||||
|
local char = string.sub(name, i, i)
|
||||||
|
if char == string.upper(char) then
|
||||||
|
short = short .. char
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return string.lower(short)
|
||||||
|
end
|
||||||
|
|
||||||
|
local snippets = {
|
||||||
|
|
||||||
|
snip('func', {
|
||||||
|
text('func '),
|
||||||
|
node(1, {
|
||||||
|
func(function(args)
|
||||||
|
if string.len(args[1][1]) > 0 then
|
||||||
|
return '(' .. short_name(args[1][1]) .. ' *'
|
||||||
|
end
|
||||||
|
return ''
|
||||||
|
end, key('type')),
|
||||||
|
ins(1, '', { key = 'type' }),
|
||||||
|
func(function(args)
|
||||||
|
if string.len(args[1][1]) > 0 then
|
||||||
|
return ') '
|
||||||
|
end
|
||||||
|
return ''
|
||||||
|
end, key('type')),
|
||||||
|
}),
|
||||||
|
ins(2, 'name'),
|
||||||
|
text('('),
|
||||||
|
ins(3, ''),
|
||||||
|
text(') '),
|
||||||
|
ins(4, '', { key = 'return' }),
|
||||||
|
func(function(args)
|
||||||
|
if string.len(args[1][1]) > 0 then
|
||||||
|
return ' '
|
||||||
|
end
|
||||||
|
return ''
|
||||||
|
end, key('return')),
|
||||||
|
text({ '{', '\t' }),
|
||||||
|
ins(0, ''),
|
||||||
|
text({ '', '}' }),
|
||||||
|
}),
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return snippets
|
||||||
13
snippets/go.snippets
Normal file
13
snippets/go.snippets
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Go SnipMate snippets
|
||||||
|
|
||||||
|
snippet main
|
||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
$0
|
||||||
|
}
|
||||||
|
|
||||||
|
snippet err
|
||||||
|
if err != nil {
|
||||||
|
$0
|
||||||
|
}
|
||||||
15
snippets/python.snippets
Normal file
15
snippets/python.snippets
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Python SnipMate snippets
|
||||||
|
|
||||||
|
snippet main
|
||||||
|
def main():
|
||||||
|
${0:pass}
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
exit(130)
|
||||||
|
|
||||||
|
snippet debug
|
||||||
|
import ipdb; ipdb.set_trace()
|
||||||
6
snippets/rst.snippets
Normal file
6
snippets/rst.snippets
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# reStructuredText snippets
|
||||||
|
|
||||||
|
snippet code
|
||||||
|
.. code-block:: ${1:language}
|
||||||
|
|
||||||
|
$0
|
||||||
Reference in New Issue
Block a user