Archived
0
0
Fork 0

added lspsaga

This commit is contained in:
Daryl Ronningen 2022-07-09 13:17:26 -07:00
parent 8df1114f70
commit 33160575bb
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
7 changed files with 49 additions and 128 deletions

View file

@ -13,6 +13,11 @@ if not snip_status_ok then
return
end
local lspkind_status_ok, lspkind = pcall(require, "lspkind")
if not lspkind_status_ok then
return
end
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function()
@ -22,34 +27,6 @@ end
npm.setup({})
local kind_icons = {
Text = "",
Method = "m",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
cmp.setup({
snippet = {
expand = function(args)
@ -99,8 +76,10 @@ cmp.setup({
},
formatting = {
fields = { "abbr", "kind", "menu" },
format = function(entry, vim_item)
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
format = lspkind.cmp_format({
mode = "symbol_text",
maxwidth = 50,
before = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = "[LSP]",
copilot = "[COPILOT]",
@ -108,10 +87,11 @@ cmp.setup({
nvim_lua = "[NVIM_LUA]",
luasnip = "[SNIPPET]",
buffer = "[BUFFER]",
path = "[PATH6]",
path = "[PATH]",
})[entry.source.name]
return vim_item
end,
}),
},
sources = {
{ name = "copilot" },

View file

@ -52,29 +52,22 @@ end
local function lsp_keymaps(bufnr)
local opts = { noremap = true, silent = true }
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", ":lua vim.lsp.buf.declaration()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", ":lua vim.lsp.buf.definition()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", ":lua vim.lsp.buf.hover()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", ":lua vim.lsp.buf.implementation()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", ":lua vim.lsp.buf.signature_help()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "grn", ":lua vim.lsp.buf.rename()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", ":lua vim.lsp.buf.references()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gca", ":lua vim.lsp.buf.code_action()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", ":lua vim.diagnostic.open_float()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", ':lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", ':lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", ":Lspsaga lsp_finder<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", ":Lspsaga preview_definition<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", ":Lspsaga hover_doc<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", ":Lspsaga implement<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", ":Lspsaga signature_help<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "grn", ":Lspsaga rename<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", ":Lspsaga lsp_finder<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gca", ":Lspsaga code_action<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", ":Lspsaga diagnostic_jump_next<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", ":Lspsaga diagnostic_jump_prev<CR>", opts)
vim.cmd([[ command! Format execute 'lua vim.lsp.buf.formatting()' ]])
end
M.on_attach = function(client, bufnr)
lsp_keymaps(bufnr)
lsp_highlight_document(client)
if client.server_capabilities.documentSymbolProvider then
local navic = require("nvim-navic")
navic.attach(client, bufnr)
end
end
local capabilities = vim.lsp.protocol.make_client_capabilities()

View file

@ -2,3 +2,5 @@ require("user.lsp.handlers").setup()
require("user.lsp.mason")
require("user.lsp.nullls")
require("user.lsp.signature")
require("user.lsp.lspsaga")
require("user.lsp.lightbulb")

13
lua/user/lsp/lspsaga.lua Normal file
View file

@ -0,0 +1,13 @@
local status_ok, lspsaga = pcall(require, "lspsaga")
if not status_ok then
return
end
lspsaga.init_lsp_saga({
symbol_in_winbar = {
enable = true,
separator = "",
show_file = true,
click_support = false,
},
})

View file

@ -36,7 +36,6 @@ vim.opt.incsearch = true
vim.opt.colorcolumn = "120"
vim.opt.list = true
vim.opt.listchars:append("lead:.")
vim.opt.winbar = "%{%v:lua.require'user.winbar'.get_winbar()%}"
vim.cmd("set whichwrap+=<,>,[,],h,l")
vim.cmd([[set iskeyword+=-]])

View file

@ -41,6 +41,7 @@ return packer.startup(function(use)
use("nvim-lua/popup.nvim")
use("nvim-lua/plenary.nvim")
use("kyazdani42/nvim-web-devicons")
use("antoinemadec/FixCursorHold.nvim")
-- Themes
use("shaunsingh/nord.nvim")
@ -69,9 +70,9 @@ return packer.startup(function(use)
use("ray-x/lsp_signature.nvim")
-- use("github/copilot.vim") -- ENABLE ON FIRST TIME ONLY!
use("zbirenbaum/copilot.lua")
-- Trouble
use("folke/trouble.nvim")
use("onsails/lspkind.nvim")
use("glepnir/lspsaga.nvim")
-- Telescope
use("nvim-telescope/telescope.nvim")
@ -126,9 +127,6 @@ return packer.startup(function(use)
-- Colorizer
use("norcalli/nvim-colorizer.lua")
-- Navic
use("SmiteshP/nvim-navic")
-- Wakatime
use("wakatime/vim-wakatime")

View file

@ -1,64 +0,0 @@
local M = {}
local navic = require("nvim-navic")
local function get_buf_option(opt)
local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt)
if not status_ok then
return nil
else
return buf_option
end
end
local function is_empty(s)
return s == nil or s == ""
end
M.winbar_filetype_exclude = {
"help",
"startify",
"dashboard",
"packer",
"neogitstatus",
"NvimTree",
"Trouble",
"alpha",
"lir",
"Outline",
"spectre_panel",
"toggleterm",
}
local excludes = function()
if vim.tbl_contains(M.winbar_filetype_exclude, vim.bo.filetype) then
vim.opt_local.winbar = nil
return true
end
return false
end
local function get_filename()
return "%#WinBarFilename#" .. "%t" .. "%*"
end
local function get_location()
local location = navic.get_location()
if not is_empty(location) then
return "%#WinBarContext#" .. " " .. ">" .. " " .. location .. "%*"
end
return ""
end
function M.get_winbar()
if excludes() then
return ""
end
if navic.is_available() then
return get_filename() .. get_location()
else
return get_filename()
end
end
return M