Clean up config a little

This commit is contained in:
Anthony Rose 2024-12-04 13:21:37 +00:00
parent 13d3559a63
commit 70a7939080
3 changed files with 77 additions and 35 deletions

View file

@ -1,37 +1,4 @@
vim.cmd("runtime vimrc") vim.cmd("runtime vimrc")
if (vim.fn.has 'win32' == 1) then require('ant_tabcomplete')
require'lspconfig'.powershell_es.setup{ require('ant_lsp')
bundle_path = os.getenv("LOCALAPPDATA") .. '\\PowerShellEditorServices',
shell = 'powershell.exe',
}
else
require'lspconfig'.powershell_es.setup{
bundle_path = os.getenv("HOME") .. '/opt/PowerShellEditorServices',
}
end
require'lspconfig'.gopls.setup{}
-- None of this should be needed from 0.11.0 (except maybe gd).
do
vim.keymap.set('n', 'gd', function()
vim.lsp.buf.definition()
end, { desc = 'vim.lsp.buf.definition()' })
vim.keymap.set('n', 'grn', function()
vim.lsp.buf.rename()
end, { desc = 'vim.lsp.buf.rename()' })
vim.keymap.set({ 'n', 'x' }, 'gra', function()
vim.lsp.buf.code_action()
end, { desc = 'vim.lsp.buf.code_action()' })
vim.keymap.set('n', 'grr', function()
vim.lsp.buf.references()
end, { desc = 'vim.lsp.buf.references()' })
vim.keymap.set('i', '<C-S>', function()
vim.lsp.buf.signature_help()
end, { desc = 'vim.lsp.buf.signature_help()' })
end

35
lua/ant_lsp.lua Normal file
View file

@ -0,0 +1,35 @@
if (vim.fn.has 'win32' == 1) then
require'lspconfig'.powershell_es.setup{
bundle_path = os.getenv("LOCALAPPDATA") .. '\\PowerShellEditorServices',
shell = 'powershell.exe',
}
else
require'lspconfig'.powershell_es.setup{
bundle_path = os.getenv("HOME") .. '/opt/PowerShellEditorServices',
}
end
require'lspconfig'.gopls.setup{}
-- None of this should be needed from 0.11.0 (except maybe gd).
do
vim.keymap.set('n', 'gd', function()
vim.lsp.buf.definition()
end, { desc = 'vim.lsp.buf.definition()' })
vim.keymap.set('n', 'grn', function()
vim.lsp.buf.rename()
end, { desc = 'vim.lsp.buf.rename()' })
vim.keymap.set({ 'n', 'x' }, 'gra', function()
vim.lsp.buf.code_action()
end, { desc = 'vim.lsp.buf.code_action()' })
vim.keymap.set('n', 'grr', function()
vim.lsp.buf.references()
end, { desc = 'vim.lsp.buf.references()' })
vim.keymap.set('i', '<C-S>', function()
vim.lsp.buf.signature_help()
end, { desc = 'vim.lsp.buf.signature_help()' })
end

40
lua/ant_tabcomplete.lua Normal file
View file

@ -0,0 +1,40 @@
vim.opt.completeopt = {'menu', 'menuone', 'noselect', 'noinsert'}
vim.opt.shortmess:append('c')
local function tab_complete()
if vim.fn.pumvisible() == 1 then
-- navigate to next item in completion menu
return '<Down>'
end
local c = vim.fn.col('.') - 1
local is_whitespace = c == 0 or vim.fn.getline('.'):sub(c, c):match('%s')
if is_whitespace then
-- insert tab
return '<Tab>'
end
local lsp_completion = vim.bo.omnifunc == 'v:lua.vim.lsp.omnifunc'
if lsp_completion then
-- trigger lsp code completion
return '<C-x><C-o>'
end
-- suggest words in current buffer
return '<C-x><C-n>'
end
local function tab_prev()
if vim.fn.pumvisible() == 1 then
-- navigate to previous item in completion menu
return '<Up>'
end
-- insert tab
return '<Tab>'
end
vim.keymap.set('i', '<Tab>', tab_complete, {expr = true})
vim.keymap.set('i', '<S-Tab>', tab_prev, {expr = true})