feat: add nvim-lsputils
This commit is contained in:
parent
5502fdb092
commit
ab3a130351
@ -5,7 +5,7 @@ lspkind.init()
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
local has_words_before = function()
|
||||
local function has_words_before()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
@ -1,3 +1,3 @@
|
||||
local map = require 'utils.map'
|
||||
|
||||
map('n', '<leader>g', ':G<cr>', { silent = true })
|
||||
map('n', '<leader>gg', ':G<cr>', { silent = true })
|
||||
|
@ -1,3 +1,4 @@
|
||||
require "lsp_signature".setup{
|
||||
hint_enable = false
|
||||
hint_enable = false,
|
||||
toggle_key = '<C-x>'
|
||||
}
|
||||
|
43
lua/config/lsputils.lua
Normal file
43
lua/config/lsputils.lua
Normal file
@ -0,0 +1,43 @@
|
||||
if vim.fn.has('nvim-0.5.1') == 1 then
|
||||
vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
|
||||
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
|
||||
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
|
||||
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
|
||||
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
|
||||
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
|
||||
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
|
||||
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler
|
||||
else
|
||||
local bufnr = vim.api.nvim_buf_get_number(0)
|
||||
vim.lsp.handlers['textDocument/codeAction'] = function(_, _, actions)
|
||||
require('lsputil.codeAction').code_action_handler(nil, actions, nil, nil, nil)
|
||||
end
|
||||
|
||||
vim.lsp.handlers['textDocument/references'] = function(_, _, result)
|
||||
require('lsputil.locations').references_handler(nil, result, { bufnr = bufnr }, nil)
|
||||
end
|
||||
|
||||
vim.lsp.handlers['textDocument/definition'] = function(_, method, result)
|
||||
require('lsputil.locations').definition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
|
||||
end
|
||||
|
||||
vim.lsp.handlers['textDocument/declaration'] = function(_, method, result)
|
||||
require('lsputil.locations').declaration_handler(nil, result, { bufnr = bufnr, method = method }, nil)
|
||||
end
|
||||
|
||||
vim.lsp.handlers['textDocument/typeDefinition'] = function(_, method, result)
|
||||
require('lsputil.locations').typeDefinition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
|
||||
end
|
||||
|
||||
vim.lsp.handlers['textDocument/implementation'] = function(_, method, result)
|
||||
require('lsputil.locations').implementation_handler(nil, result, { bufnr = bufnr, method = method }, nil)
|
||||
end
|
||||
|
||||
vim.lsp.handlers['textDocument/documentSymbol'] = function(_, _, result, _, bufn)
|
||||
require('lsputil.symbols').document_handler(nil, result, { bufnr = bufn }, nil)
|
||||
end
|
||||
|
||||
vim.lsp.handlers['textDocument/symbol'] = function(_, _, result, _, bufn)
|
||||
require('lsputil.symbols').workspace_handler(nil, result, { bufnr = bufn }, nil)
|
||||
end
|
||||
end
|
@ -80,7 +80,7 @@ local function usePlugins(use, use_rocks)
|
||||
-- Movement utilities
|
||||
use 'tpope/vim-unimpaired'
|
||||
|
||||
-- LSP config
|
||||
-- LSP
|
||||
use {
|
||||
'neovim/nvim-lspconfig',
|
||||
config = [[require 'config.lspconfig']],
|
||||
@ -91,6 +91,13 @@ local function usePlugins(use, use_rocks)
|
||||
config = [[require 'config.lspinstaller']]
|
||||
}
|
||||
|
||||
-- LSP utils
|
||||
use {
|
||||
'RishabhRD/nvim-lsputils',
|
||||
config = [[require 'config.lsputils']],
|
||||
requires = 'RishabhRD/popfix'
|
||||
}
|
||||
|
||||
-- Completion
|
||||
use { 'onsails/lspkind-nvim' }
|
||||
use {
|
||||
|
Loading…
Reference in New Issue
Block a user