Start cleaning up lsp-zero
This commit is contained in:
parent
fee8ac3d5c
commit
f491f44e16
@ -35,8 +35,6 @@ call plug#begin(stdpath('config') . '/plugged')
|
|||||||
Plug 'L3MON4D3/LuaSnip'
|
Plug 'L3MON4D3/LuaSnip'
|
||||||
Plug 'hrsh7th/cmp-buffer'
|
Plug 'hrsh7th/cmp-buffer'
|
||||||
Plug 'hrsh7th/cmp-path'
|
Plug 'hrsh7th/cmp-path'
|
||||||
Plug 'VonHeikemen/lsp-zero.nvim', {'branch': 'v3.x'}
|
|
||||||
|
|
||||||
Plug 'huggingface/llm.nvim'
|
Plug 'huggingface/llm.nvim'
|
||||||
" lsp-zero end
|
" lsp-zero end
|
||||||
call plug#end()
|
call plug#end()
|
||||||
@ -70,35 +68,19 @@ lua <<EOF
|
|||||||
vim.api.nvim_set_keymap('n', '<C-b>', ':Make<CR>', {noremap = true})
|
vim.api.nvim_set_keymap('n', '<C-b>', ':Make<CR>', {noremap = true})
|
||||||
|
|
||||||
-- LSP Setup /////////////////////////////////////////////////////////////////////////////////////
|
-- LSP Setup /////////////////////////////////////////////////////////////////////////////////////
|
||||||
local lsp_zero = require('lsp-zero')
|
|
||||||
lsp_zero.on_attach(function(client, bufnr)
|
|
||||||
-- see :help lsp-zero-keybindings
|
|
||||||
-- to learn the available actions
|
|
||||||
lsp_zero.default_keymaps({
|
|
||||||
buffer = bufnr,
|
|
||||||
exclude = {'<F3>'}, -- Disable code-format of current buffer
|
|
||||||
})
|
|
||||||
local opts = {buffer = bufnr}
|
|
||||||
|
|
||||||
vim.keymap.set({'v', 'x'}, 'gq', function()
|
|
||||||
vim.lsp.buf.format({async = false, timeout_ms = 10000})
|
|
||||||
end, opts)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- to learn how to use mason.nvim with lsp-zero
|
|
||||||
-- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guide/integrate-with-mason-nvim.md
|
|
||||||
require('mason').setup({})
|
require('mason').setup({})
|
||||||
require('mason-lspconfig').setup({
|
require('mason-lspconfig').setup({
|
||||||
ensure_installed = { "clangd" },
|
ensure_installed = { "clangd" },
|
||||||
handlers = {
|
automatic_enable = true
|
||||||
lsp_zero.default_setup,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
local cmp = require('cmp')
|
local opts = { noremap = true, silent = true }
|
||||||
local cmp_action = require('lsp-zero').cmp_action()
|
vim.keymap.set("n", "<F2>", vim.lsp.buf.rename, opts)
|
||||||
local cmp_format = require('lsp-zero').cmp_format({details = true})
|
vim.keymap.set("n", "<F4>", vim.lsp.buf.code_action, opts)
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||||
|
|
||||||
|
local cmp = require('cmp')
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
sources = {
|
sources = {
|
||||||
{name = 'nvim_lsp'},
|
{name = 'nvim_lsp'},
|
||||||
@ -107,9 +89,9 @@ lua <<EOF
|
|||||||
|
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<Tab>'] = cmp_action.luasnip_supertab(),
|
|
||||||
['<S-Tab>'] = cmp_action.luasnip_shift_supertab(),
|
|
||||||
['<CR>'] = cmp.mapping.confirm({select = false}),
|
['<CR>'] = cmp.mapping.confirm({select = false}),
|
||||||
|
['<Tab>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||||
|
['<S-Tab>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||||
}),
|
}),
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
@ -219,6 +201,7 @@ lua <<EOF
|
|||||||
-- a C++ buffer constantly toggles the sign column on and off as you change
|
-- a C++ buffer constantly toggles the sign column on and off as you change
|
||||||
-- modes which is very visually distracting.
|
-- modes which is very visually distracting.
|
||||||
signs = false,
|
signs = false,
|
||||||
|
virtual_text = true
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Automatically scroll to bottom of quickfix window when opened
|
-- Automatically scroll to bottom of quickfix window when opened
|
||||||
|
Loading…
x
Reference in New Issue
Block a user