Compare commits

...

70 Commits

Author SHA1 Message Date
Kenneth Benzie (Benie)
d21cd45701 temp! 2024-05-24 11:20:11 +01:00
Kenneth Benzie (Benie)
9d5868304f Add reStructureText snippets file 2024-05-24 11:05:18 +01:00
56beb52997 Simplify clangd command 2024-05-22 21:35:47 +01:00
48ad466bd3 Vanquish ftdetect, long live vim.filetype.add() 2024-05-22 21:29:36 +01:00
4499dee3d6 Move statusline.lua to plugin directory 2024-05-22 21:08:27 +01:00
d75531ae3d Make statusline functions global 2024-05-22 21:06:28 +01:00
Kenneth Benzie (Benie)
9f0d9890fd Ensure all LSP capabilities are broadcast 2024-05-20 11:15:11 +01:00
ccec3232b5 Make it easier to have multiple colorscheme plugins 2024-05-18 14:05:22 +01:00
Kenneth Benzie (Benie)
ed74a5909a Use clangd --completion-style=detailed option 2024-05-17 11:47:18 +01:00
5da8a3c2f6 Move ui.lua to plugin directory 2024-05-14 22:50:55 +01:00
75f9b205bd Move build.lua to plugin directory 2024-05-14 22:45:48 +01:00
f5ab986397 Set vim.g.mapleader as early as possible 2024-05-14 22:45:20 +01:00
4ee7596ffc Move autocmds.lua to plugin directory 2024-05-14 22:42:09 +01:00
19d7ac86f2 Move netrw.lua to plugin directory 2024-05-14 22:41:06 +01:00
3ff031990a Move commands.lua to plugin directory 2024-05-14 22:39:12 +01:00
9de31c4c59 Move settings.lua to plugin directory 2024-05-14 22:36:48 +01:00
500e786a70 Move mappings.lua to plugin directory 2024-05-14 22:35:41 +01:00
94c332368f Make most generic mappings silent 2024-05-14 22:34:49 +01:00
eade51e5b9 Add go ftplugin 2024-05-14 22:17:56 +01:00
61e4807f55 Add markdown-inline tree-sitter 2024-05-14 21:42:16 +01:00
Kenneth Benzie (Benie)
f717fd0468 Add Python debug snippet 2024-05-09 11:50:36 +01:00
5f2c45050c Add mapping for :ClangdSwitchSourceHeader LSP extension 2024-05-03 11:40:19 +01:00
3e94d25caf Add some more kaomoji snippets 2024-05-02 23:39:08 +01:00
Kenneth Benzie (Benie)
06c8f8a751 Add ac/ic text objects for outer/inner class 2024-05-02 16:15:54 +01:00
d4228e37b8 Keep tweaking noice 2024-04-29 21:25:27 +01:00
e3d4651062 Add Python main snippet 2024-04-23 22:52:06 +01:00
09c785eee9 Set a limit to how wide the completion menu can be 2024-04-20 12:37:31 +01:00
63d2a3ffd3 Add not about builtin snippets in v0.10.0 2024-04-19 21:01:07 +01:00
b5adbd3343 Add tabline highlight group overrides 2024-04-18 18:56:39 +01:00
Kenneth Benzie (Benie)
985df79d1a Use telescope.builtin Lua functions in mappings 2024-04-17 12:21:26 +01:00
c190e42da5 Make sure the textwidth to 72 in gitcommit filetype 2024-04-16 00:07:09 +01:00
8d93cbdf57 Switch to mason.nvim fork with virtualenv fallback 2024-04-15 23:45:30 +01:00
1ba816fcf8 Of course pyright is an npm package 2024-04-15 21:52:48 +01:00
9d5b798385 Cleanup conditional language server installs 2024-04-15 21:52:48 +01:00
727ebc81a8 Handle mason.nvim install deps not existing 2024-04-15 21:52:48 +01:00
a3024efb61 Fix mapping conflict 2024-04-13 13:42:09 +01:00
0b9c2765d3 Make sure builtin UI config is actually loaded 2024-04-13 13:41:13 +01:00
a655cbe3d9 Add title to diagnostics floating window 2024-04-13 13:40:49 +01:00
428cea9747 Cleanup some lint 2024-04-13 13:28:58 +01:00
ada48d79f4 Don't explicitly name plugins 2024-04-13 10:55:37 +01:00
cfac2daaee Cleanup diagnostics mappings config 2024-04-13 10:55:21 +01:00
e08e933732 Fix typos in completions keymap configs 2024-04-13 10:54:52 +01:00
c07896bfad Use telescope.builtin's for more LSP mappings 2024-04-13 10:21:41 +01:00
4c8f6cbc8b Organise completion plugin dependencies 2024-04-13 10:02:25 +01:00
e5e2453efb Move lsp/diagnostic UI config to separate file 2024-04-13 10:02:25 +01:00
e11b4d54a2 Split snippets config out of completions config 2024-04-13 10:02:25 +01:00
a4377b22ac Split diagnostics config out of completions config 2024-04-13 10:02:25 +01:00
6372e8f63c Change to yellow search highlight 2024-04-13 00:05:43 +01:00
9a0f74eb97 Make float background highlights match 2024-04-13 00:04:29 +01:00
0957a4853c Add nvim-treesitter-context plugin 2024-04-12 00:43:20 +01:00
d90ae27edf Add todo's for two LSP plugins of interest 2024-04-12 00:31:50 +01:00
6392327a28 Add ray-x/lsp_signature.nvim plugin
Improves the built-in signature help UI, enables toggling of signatures,
and displays multiple signatures when available.
2024-04-12 00:20:47 +01:00
959e9e5c52 Add kbenzie/cmp-git plugin
This is a fork of https://github.com/petertriho/cmp-git with a revert of
a bug fix that appears to have introduced a bug.
2024-04-11 23:23:06 +01:00
f254665710 Add completion to :Mkdir 2024-04-11 21:56:37 +01:00
253f6f306d Fix Lue typo to Lua :D 2024-04-09 22:34:43 +01:00
0e427facfa Add fixme to :Rg comamnd 2024-04-09 21:05:17 +01:00
fd4cefb74b Add nvim-treesitter-endwise todo 2024-04-08 21:14:44 +01:00
25885dd7c7 Remove FIXME's that 3daca6d6 disabled 2024-04-08 21:06:11 +01:00
27f1e54777 Remove FIXME that was already fixed in 9f1c0228 2024-04-08 21:04:24 +01:00
046e33c614 Re-enable buffer text completion source 2024-04-08 20:57:07 +01:00
6c59054a7a Change touble toogle mapping 2024-04-08 20:55:03 +01:00
2098949e9c Add :Chmod command to change mode bits 2024-04-08 20:52:47 +01:00
eee4944354 Use function style for vim.cmd instead of string style 2024-04-07 19:12:38 +01:00
fe19c35f36 nvim v0.10.0 will have a builtin OSC52 provider 2024-04-07 19:01:27 +01:00
057c706699 Add :Mkdir command to create directories 2024-04-07 18:59:50 +01:00
93bea02a48 Cleanup command documentation comments 2024-04-07 18:45:58 +01:00
04b5e6e4fb Add :Move command to move files around 2024-04-07 18:39:34 +01:00
4b4a1dbf38 Cleanup :Rename implementation 2024-04-07 18:38:20 +01:00
d92a312992 Add :Rg[!] command
:Rg <STRING> grep for the string and fuzzy find the results, bang to
enable regex in search term
2024-04-06 15:41:27 +01:00
ba4e6dc233 Ensure LuaSnips dependencies are met 2024-04-06 15:39:30 +01:00
34 changed files with 402 additions and 230 deletions

View File

@@ -1 +0,0 @@
autocmd BufNewFile,BufReadPost CMakeCache.txt set filetype=cmakecache

View File

@@ -1,2 +0,0 @@
" Force *.def to C++ filetype for LLVM
au BufNewFile,BufReadPost *.def set filetype=cpp

View File

@@ -1,3 +0,0 @@
" Set .ll files to LLVM IR filetype
au BufNewFile,BufReadPost *.ll set filetype=llvm
au BufNewFile,BufReadPost *.test set filetype=llvm

View File

@@ -1,3 +0,0 @@
" Force *.md to markdown filetype
au BufNewFile,BufReadPost *.md set filetype=markdown
au BufNewFile,BufReadPost *.ronn set filetype=markdown

View File

@@ -1,2 +0,0 @@
" Force *.cl to OpenCL C filetype
au BufNewFile,BufReadPost *.cl set filetype=opencl

View File

@@ -1,3 +0,0 @@
" Force lit.cfg/lit.local.cfg to be Python
au BufNewFile,BufReadPost lit.cfg set filetype=python
au BufNewFile,BufReadPost lit.local.cfg set filetype=python

View File

@@ -1 +0,0 @@
autocmd BufNewFile,BufReadPost */requirements.txt set filetype=requirements

View File

@@ -1,2 +0,0 @@
" Force *.td to tablegen filetype
au BufNewFile,BufReadPost *.td set filetype=tablegen

View File

@@ -1,3 +0,0 @@
" Force .enter/.exit to be zsh
au BufNewFile,BufReadPost .enter set filetype=zsh
au BufNewFile,BufReadPost .exit set filetype=zsh

View File

@@ -1,4 +1,5 @@
vim.opt.spell = true
vim.opt.textwidth = 72
-- Auto-wrap text using textwidth
vim.opt.formatoptions:append('t')

6
after/ftplugin/go.lua Normal file
View File

@@ -0,0 +1,6 @@
vim.opt.expandtab = false
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.wo.listchars = 'extends:»,nbsp:⦸,precedes:«,tab: ,trail:·'
vim.bo.formatprg = 'gofmt'

View File

@@ -1,10 +1,5 @@
require('settings')
require('mappings')
require('commands')
require('netrw')
require('autocmds')
require('statusline')
require('build')
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then

View File

@@ -1,59 +0,0 @@
vim.g.mapleader = ' '
-- Quick write
vim.keymap.set('n', '<leader>w', ':w!<CR>', { remap = false })
-- Treat long lines as line containing breaks
vim.keymap.set('n', 'j', 'gj', { remap = false })
vim.keymap.set('n', 'k', 'gk', { remap = false })
vim.keymap.set('n', '<leader>tn', ':tabnew<Space>', { remap = false })
vim.keymap.set('n', '<leader>tc', ':tabclose<CR>', { remap = false })
vim.keymap.set('n', '<leader>to', ':tabonly<CR>', { remap = false })
vim.keymap.set('n', '<leader>tm', ':tabmove<Space>', { remap = false })
-- Quickly access spelling menu
vim.keymap.set('i', '<C-s>', '<C-g>u<C-X>s', { remap = false })
vim.keymap.set('n', '<C-s>', 'i<C-g>u<C-X>s', { remap = false })
-- Clear search highlights
vim.keymap.set('n', '<leader><Space>', ':nohlsearch<CR>', { remap = false })
-- Disable 'Q' from opening Ex mode
vim.keymap.set('n', 'Q', '<nop>', { remap = false })
-- 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', { remap = false })
vim.keymap.set('', '<leader>Y', '"+Y', { remap = false })
vim.keymap.set('', '<leader>p', '"+p', { remap = false })
vim.keymap.set('', '<leader>P', '"+P', { remap = false })
-- end
-- 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>', { remap = true })
-- Mappings to make navigating :Termdebug
local opts = { remap = false, silent = true }
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)

View File

@@ -1,4 +1,4 @@
return {
local kanagawa = {
'rebelot/kanagawa.nvim',
config = function()
local kanagawa = require('kanagawa')
@@ -8,8 +8,12 @@ return {
bg = '#080808',
bg_m3 = '#262626',
bg_gutter = '#121212',
-- bg_search = '#404000',
bg_search = '#404000',
bg_visual = '#202020',
float = {
bg = '#080808',
bg_border = '#080808',
}
},
}
@@ -21,8 +25,15 @@ return {
kanagawa.load('dragon')
-- 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.highligh('TreesitterContext', 'guibg=' .. dragon.ui.bg_gutter)
vim.cmd.highlight('link zshTodo Comment')
end
}
return kanagawa

View File

@@ -1,74 +1,106 @@
-- Language servers
local ensure_installed = {
'clangd', -- C/C++
'lua_ls', -- Lua
'opencl_ls', -- OpenCL
}
if vim.fn.executable('npm') == 1 then
local ensure_install_from_npm = {
'ansiblels', -- Ansible
'bashls', -- Bash
'docker_compose_language_service', -- Docker Compose
'dockerls', -- Dockerfile
'html', -- HTML
'jsonls', -- JSON
'pyright', -- Python
'vimls', -- VimScript
'yamlls', -- YAML
}
for _, package in ipairs(ensure_install_from_npm) do
table.insert(ensure_installed, package)
end
end
if vim.fn.executable('pip') == 1 then
local ensure_install_from_pip = {
'cmake', -- CMake
'esbonio', -- Sphinx
'ruff_lsp', -- Python
}
for _, package in ipairs(ensure_install_from_pip) do
table.insert(ensure_installed, package)
end
end
if vim.fn.has('win32') == 1 then
table.insert(ensure_installed, 'powershell_es')
end
return {
'neovim/nvim-lspconfig',
dependencies = {
-- Language server management plugins
'williamboman/mason.nvim',
-- 'williamboman/mason.nvim',
'kbenzie/mason.nvim',
'williamboman/mason-lspconfig.nvim',
-- Completion plugins
'hrsh7th/cmp-nvim-lsp', -- Source for built-in language server client
'hrsh7th/cmp-buffer', -- Source for buffer words
'hrsh7th/cmp-path', -- Source for filesystem paths
'hrsh7th/cmp-cmdline', -- Source for command-line
'hrsh7th/nvim-cmp', -- Completion engine combines and use the above
-- Completion sources plugins
'hrsh7th/cmp-nvim-lsp', -- Source for built-in language server client
'saadparwaiz1/cmp_luasnip', -- Source for LuaSnip snippets
'hrsh7th/cmp-buffer', -- Source for buffer words
'hrsh7th/cmp-path', -- Source for filesystem paths
'kbenzie/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/neodev.nvim',
-- Expose clangd extensions
'p00f/clangd_extensions.nvim',
-- LSP UI plugins
'aznhe21/actions-preview.nvim',
'j-hui/fidget.nvim',
'folke/trouble.nvim',
'nvim-tree/nvim-web-devicons',
'ray-x/lsp_signature.nvim',
-- Lue vim module support in lua language server
'folke/neodev.nvim',
-- Snippet pluggins
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
-- Expose clangd extensions
'p00f/clangd_extensions.nvim',
-- TODO: https://github.com/b0o/SchemaStore.nvim
-- TODO: https://github.com/jmbuhr/otter.nvim
-- TODO: https://github.com/nvimtools/none-ls.nvim
-- TODO: https://github.com/mfussenegger/nvim-dap
-- TODO: https://github.com/rcarriga/nvim-dap-ui
},
config = function()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend(
'force', capabilities, require('cmp_nvim_lsp').default_capabilities())
require('mason').setup()
require('mason-lspconfig').setup({
automatic_installation = false,
ensure_installed = {
'ansiblels', -- Ansible
'bashls', -- Bash
'clangd', -- C/C++
'cmake', -- Cmake
'docker_compose_language_service', -- Docker Compose
'dockerls', -- Dockerfile
'esbonio', -- Sphinx
'html', -- HTML
'jsonls', -- JSON
'lemminx', -- XML
'lua_ls', -- Lua
'opencl_ls', -- OpenCL
'powershell_es', -- Powershell
'pyright', -- Python
'ruff_lsp', -- Python
'vimls', -- VimScript
'yamlls', -- YAML
},
ensure_installed = ensure_installed,
handlers = {
-- Default handler, sets up everything unless a custom language server
-- setup handler is defined below
function(server_name)
require('lspconfig')[server_name].setup({})
require('lspconfig')[server_name].setup({
capabilities = capabilities,
})
end,
['clangd'] = function()
require('lspconfig').clangd.setup({
capabilities = capabilities,
cmd = { 'clangd', '--completion-style=detailed' }
})
end,
['lua_ls'] = function()
require('neodev').setup()
require('lspconfig').lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
@@ -82,6 +114,7 @@ return {
['pyright'] = function()
require('lspconfig').pyright.setup({
capabilities = capabilities,
settings = {
pyright = {
disableOrganizeImports = true, -- Use ruff import sorter instead
@@ -116,9 +149,23 @@ return {
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
-- { name = 'buffer' },
{ name = 'buffer' },
{ name = 'path' },
-- { name = 'cmdline' },
{ name = 'git' },
},
formatting = {
format = function(entry, 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 = {
@@ -126,35 +173,7 @@ return {
documentation = cmp.config.window.bordered(),
},
})
-- 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 diagnostics UI
vim.diagnostic.config({
float = {
border = 'rounded', -- Enable rounded border on floats
},
virtual_text = false, -- Disable trailing virtual text
})
-- Diagnostics mappings
-- TODO: trouble.nvim mappings instead? https://youtu.be/MuUrCcvE-Yw?t=631
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { remap = false })
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { remap = false })
vim.keymap.set('n', '<leader>sd', vim.diagnostic.open_float, { remap = false })
vim.keymap.set('n', '<leader>sq', vim.diagnostic.setqflist, { remap = false })
require("cmp_git").setup({})
-- Mappings created when LSP is attached to a buffer
local augroup = vim.api.nvim_create_augroup('lsp', { clear = true })
@@ -165,17 +184,19 @@ return {
local opts = { noremap = true, buffer = ev.buf }
-- Fixit mapping, or close enough, actually any code action
vim.keymap.set('n', '<leader>fi',
require('actions-preview').code_actions, opts)
vim.keymap.set('n', '<leader>fi', require('actions-preview').code_actions, opts)
-- Goto mappings
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
local tb = require('telescope.builtin')
vim.keymap.set('n', 'gd', tb.lsp_definitions, opts)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', 'go', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, opts)
vim.keymap.set('n', '<leader>ds', require('telescope.builtin').lsp_document_symbols, opts)
vim.keymap.set('n', '<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, opts)
vim.keymap.set('n', 'gi', tb.lsp_implementations, opts)
vim.keymap.set('n', 'go', tb.lsp_type_definitions, 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>ss', tb.lsp_document_symbols, opts)
vim.keymap.set('n', '<leader>sw', tb.lsp_workspace_symbols, opts)
-- Refactoring mappings
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
@@ -185,37 +206,24 @@ return {
-- |vim.lsp.buf.hover()| if the server supports it, unless
-- |'keywordprg'| was customized before calling |vim.lsp.start()|.
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('i', '<C-h>', vim.lsp.buf.signature_help, opts)
-- Format whole buffer mapping
vim.keymap.set('n', '<leader>gq', vim.lsp.buf.format, opts)
-- Swtich file using clangd extension
-- TODO: limit this to only filetypes supported by clangd
vim.keymap.set('n', '<leader>sf', ':ClangdSwitchSourceHeader<CR>', { silent = true })
end
})
-- Snippet mappings
local luasnip = require('luasnip')
luasnip.setup({})
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 })
-- 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)
-- LSP UI plugins
require('fidget').setup({})
require('trouble').setup({})
vim.keymap.set('n', '<leader>t', function()
require('trouble').toggle()
end, { remap = false })
require('lsp_signature').setup({
floating_window = true,
hint_enable = false,
toggle_key = '<C-h>',
toggle_key_flip_floatwin_setting = true,
select_signature_key = '<C-l>',
})
end
}

View File

@@ -0,0 +1,18 @@
return {
{
'folke/trouble.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
require('trouble').setup({})
local opts = { remap = false }
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<leader>ds', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '<leader>dq', function()
require('trouble').toggle()
end, opts)
end
}
}

26
lua/plugins/snippets.lua Normal file
View File

@@ -0,0 +1,26 @@
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 })
end
}

View File

@@ -1,7 +1,7 @@
return {
'kylechui/nvim-surround',
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy", -- FIXME: Causes splash screen to disappear on startup
event = "VeryLazy",
config = function()
require("nvim-surround").setup({})
end

View File

@@ -5,9 +5,11 @@ return {
'nvim-telescope/telescope-fzy-native.nvim',
'nvim-tree/nvim-web-devicons',
'axkirillov/easypick.nvim',
'catgoose/telescope-helpgrep.nvim',
},
config = function()
local telescope = require('telescope')
local actions = require('telescope.actions')
telescope.setup({
defaults = {
mappings = {
@@ -20,23 +22,39 @@ return {
['<C-s>'] = 'select_horizontal',
['<C-h>'] = 'preview_scrolling_left',
['<C-l>'] = 'preview_scrolling_right',
}
},
},
layout_config = {
height = 0.7,
}
},
},
extensions = {
helpgrep = {
mappings = {
i = {
["<CR>"] = actions.select_default,
["<C-v>"] = actions.select_vertical,
},
n = {
["<CR>"] = actions.select_default,
["<C-s>"] = actions.select_horizontal,
}
},
},
},
})
telescope.load_extension('fzy_native')
-- TODO: Add more mappings?
local builtin = require('telescope.builtin')
local opts = { noremap = true }
vim.keymap.set('n', '<leader>gF', ':Telescope find_files<CR>', opts)
vim.keymap.set('n', '<leader>gf', ':Telescope git_files<CR>', opts)
vim.keymap.set('n', '<leader>gg', ':Telescope live_grep<CR>', opts)
vim.keymap.set('n', '<leader>rg', ':Telescope grep_string<CR>', opts)
vim.keymap.set('n', '<leader>gb', ':Telescope buffers<CR>', opts)
vim.keymap.set('n', '<leader>gh', ':Telescope help_tags<CR>', opts)
vim.keymap.set('n', '<leader>gF', builtin.find_files, opts)
vim.keymap.set('n', '<leader>gf', builtin.git_files, opts)
vim.keymap.set('n', '<leader>gg', builtin.live_grep, opts)
vim.keymap.set('n', '<leader>rg', builtin.grep_string, opts)
vim.keymap.set('n', '<leader>gb', builtin.buffers, opts)
vim.keymap.set('n', '<leader>ht', builtin.help_tags, opts)
vim.keymap.set('n', '<leader>gh', require('telescope-helpgrep').live_grep, opts)
vim.keymap.set('n', '<leader>bl', builtin.current_buffer_fuzzy_find, opts)
require('easypick').setup({
pickers = { },

View File

@@ -1,5 +1,5 @@
return {
'folke/todo-comments.nvim', -- FIXME: Causes splash screen to disappear on startup
'folke/todo-comments.nvim',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
require('todo-comments').setup({

View File

@@ -2,7 +2,9 @@ return {
'nvim-treesitter/nvim-treesitter',
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
{ 'nvim-treesitter/nvim-treesitter-context', opts = {} },
-- TODO: Fork this and add CMake support
-- TODO: Add shell support (sh/bash/zsh if/for/while/etc)
'RRethy/nvim-treesitter-endwise',
},
build = ':TSUpdate',
@@ -46,6 +48,7 @@ return {
'lua',
'make',
'markdown',
'markdown_inline',
'meson',
'ninja',
'objc',
@@ -77,6 +80,9 @@ return {
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',

View File

@@ -22,11 +22,12 @@ local noice = {
signature = { enable = false },
message = { enable = false },
},
signature = { enabled = false },
})
-- Override highlight groups
vim.cmd [[ highlight NoiceCmdlinePopupBorder guibg=#080808 ]]
vim.cmd [[ highlight link NoiceCmdlinePopupBorder NoiceCmdlinePopupBorderSearch ]]
vim.cmd.highlight('NoiceCmdlinePopupBorder', 'guibg=#080808')
vim.cmd.highlight('link', 'NoiceCmdlinePopupBorder', 'NoiceCmdlinePopupBorderSearch')
end
}

View File

@@ -27,7 +27,7 @@ vim.api.nvim_create_autocmd('BufRead', {
vim.api.nvim_create_autocmd('TermOpen', {
group = group, pattern = 'term://*',
callback = function()
vim.cmd [[ startinsert ]]
vim.cmd.startinsert()
end
})

View File

@@ -32,7 +32,7 @@ function build.set_dir(dirname)
-- Restart clangd language server
-- TODO: Configure cmake language server?
on_exit = function()
vim.cmd [[ LspRestart clangd ]]
vim.cmd.LspRestart('clangd')
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
end,

View File

@@ -1,4 +1,4 @@
-- :RString Strip white psace from right of all lines, ranges supported
-- :RString strip white psace from right of all lines, ranges supported
vim.api.nvim_create_user_command('RStrip', function(opts)
local pos = vim.fn.getcurpos(vim.api.nvim_get_current_win())
local range = opts.line1 .. ',' .. opts.line2
@@ -7,13 +7,9 @@ vim.api.nvim_create_user_command('RStrip', function(opts)
vim.fn.setpos('.', pos)
end, { range = '%' })
-- :TabWidth <N> set the tab width for the current buffer
-- :TabWidth set the tab width for the current buffer
vim.api.nvim_create_user_command('TabWidth', function(opts)
-- Set the tab width for the current filetype
-- FIXME: Doesn't seem to cover all bases in neovim when editorconfig is
-- involved, specifically with pressing o/O in C++ from a line with a brace.
-- This might be related to tree-sitter indentation? Or could be that I've
-- not ported over all my filetype settings yet.
local width = tonumber(opts.args)
vim.opt.tabstop = width
vim.opt.shiftwidth = width
@@ -50,25 +46,44 @@ vim.api.nvim_create_user_command('Remove', function(opts)
vim.loop.fs_unlink(path, callback)
end, { bang = true })
-- TODO: :Move
-- :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 from = vim.fn.expand('%')
local buffer = vim.api.nvim_get_current_buf()
local to = nil
local source = vim.fn.expand('%')
local dest = nil
local dir = vim.fn.expand('%:h')
if dir == '.' then
to = opts.args
dest = opts.args
else
to = dir .. '/' .. opts.args
dest = vim.fn.resolve(dir .. '/' .. opts.args)
end
vim.loop.fs_rename(from, to, function(err, success)
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 ' .. to)
vim.cmd.edit(dest)
vim.api.nvim_buf_delete(buffer, {})
end)
end
@@ -80,6 +95,34 @@ end, {
end
})
-- TODO: :Chmod
-- :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
-- TODO: :Mkdir
-- :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 and fuzzy find the results, bang to enable
-- regex in given string
-- FIXME: Support visual select modes
vim.api.nvim_create_user_command('Rg', function(opts)
local grep_opts = { search = opts.args }
if opts.bang then
grep_opts['use_regex'] = true
end
require('telescope.builtin').grep_string(grep_opts)
end, { bang = true, nargs = '*' })

19
plugin/filetype.lua Normal file
View 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',
},
})

45
plugin/mappings.lua Normal file
View File

@@ -0,0 +1,45 @@
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)

View File

@@ -27,12 +27,11 @@ modes[116] = { name = 'Terminal', color = 'light_blue' }
modes[33] = { name = 'Shell', color = 'light_grey' }
local function highlight(group, color, attrs)
local command = 'highlight ' .. group ..
' guifg=' .. color.fg .. ' guibg=' .. color.bg
local args = { group, 'guifg=' .. color.fg, 'guibg=' .. color.bg }
if attrs then
command = command .. ' gui=' .. attrs
table.insert(args, 'gui=' .. attrs)
end
vim.cmd(command)
vim.cmd.highlight(args)
end
-- StatusLineLight is shows the mode and cursor information, it is dynamically
@@ -110,7 +109,7 @@ end
-- Define active statusline, this statusline is dynamic with StatusLineLight
-- being updated based on the current mode and only used for current buffer.
function statusline.active()
function _G.statusline_active()
local mode = get_mode()
if vim.o.buftype == 'help' then
if mode == 'Normal' then mode = 'Help' end
@@ -139,7 +138,7 @@ function statusline.active()
return generic('StatusLineLight', mode, true)
end
function statusline.inactive()
function _G.statusline_inactive()
local mode = modes[vim.fn.char2nr(vim.fn.mode())].name
local line = ''
if vim.o.buftype == 'help' then
@@ -170,7 +169,7 @@ vim.api.nvim_create_autocmd({ 'BufEnter', 'WinEnter', 'BufWinEnter' }, {
pattern = '*',
group = group,
callback = function()
vim.cmd [[ setlocal statusline=%{%v:lua.require('statusline').active()%} ]]
vim.cmd.setlocal("statusline=%{%v:lua.statusline_active()%}")
end
})
@@ -179,7 +178,7 @@ vim.api.nvim_create_autocmd({ 'BufLeave', 'WinLeave' }, {
pattern = '*',
group = group,
callback = function()
vim.cmd [[ setlocal statusline=%{%v:lua.require('statusline').inactive()%} ]]
vim.cmd.setlocal("statusline=%{%v:lua.statusline_inactive()%}")
end
})

22
plugin/ui.lua Normal file
View 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,
})

View File

@@ -1,7 +1,19 @@
# Global SnipMate snippets
snippet joy
(◦U ◡ U◦)
snippet shrug
¯\_(ツ)_/¯
snippet confuse
(ノ*・_・)ノ
snippet tableflip
(╯°▪°)╯︵┻━┻
snippet cry
(ㅠ﹏ㅠ)
snippet think
(╭ರ_•́)

15
snippets/python.snippets Normal file
View 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
View File

@@ -0,0 +1,6 @@
# reStructuredText snippets
snippet code
.. code-block:: ${1:language}
$0