Compare commits
70 Commits
2784989570
...
helpgrep
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d21cd45701 | ||
|
|
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 |
@@ -1 +0,0 @@
|
||||
autocmd BufNewFile,BufReadPost CMakeCache.txt set filetype=cmakecache
|
||||
@@ -1,2 +0,0 @@
|
||||
" Force *.def to C++ filetype for LLVM
|
||||
au BufNewFile,BufReadPost *.def set filetype=cpp
|
||||
@@ -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
|
||||
@@ -1,3 +0,0 @@
|
||||
" Force *.md to markdown filetype
|
||||
au BufNewFile,BufReadPost *.md set filetype=markdown
|
||||
au BufNewFile,BufReadPost *.ronn set filetype=markdown
|
||||
@@ -1,2 +0,0 @@
|
||||
" Force *.cl to OpenCL C filetype
|
||||
au BufNewFile,BufReadPost *.cl set filetype=opencl
|
||||
@@ -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
|
||||
@@ -1 +0,0 @@
|
||||
autocmd BufNewFile,BufReadPost */requirements.txt set filetype=requirements
|
||||
@@ -1,2 +0,0 @@
|
||||
" Force *.td to tablegen filetype
|
||||
au BufNewFile,BufReadPost *.td set filetype=tablegen
|
||||
@@ -1,3 +0,0 @@
|
||||
" Force .enter/.exit to be zsh
|
||||
au BufNewFile,BufReadPost .enter set filetype=zsh
|
||||
au BufNewFile,BufReadPost .exit set filetype=zsh
|
||||
@@ -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
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'
|
||||
9
init.lua
9
init.lua
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
18
lua/plugins/diagnostics.lua
Normal file
18
lua/plugins/diagnostics.lua
Normal 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
26
lua/plugins/snippets.lua
Normal 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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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 = { },
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
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',
|
||||
},
|
||||
})
|
||||
45
plugin/mappings.lua
Normal file
45
plugin/mappings.lua
Normal 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)
|
||||
@@ -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
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,
|
||||
})
|
||||
@@ -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
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