Browse Source

Add lsp saga

pull/14/head
Leslie Kerman 2 years ago
parent
commit
d4bfe860e2
  1. 16
      init.vim
  2. 84
      lua/configs/autocomplete.lua
  3. 2
      lua/core/init.lua
  4. 19
      lua/core/keymaps.lua
  5. 3
      lua/core/plugins.lua
  6. 10
      lua/core/theme.lua

16
init.vim

@ -7,5 +7,21 @@ if has('unix')
set thesaurus+=/usr/share/dict/words
endif
if exists("g:neovide")
" Neovide config
let g:neovide_refresh_rate=40 " come on it's just a text editor
let g:neovide_transparency=1.0
let g:neovide_scroll_animation_length = 0.3
let g:neovide_remember_window_size = v:true
let g:neovide_input_use_logo=v:true " the super/command/win key
let g:neovide_input_macos_alt_is_meta=v:false
let g:neovide_touch_deadzone=0.0
let g:neovide_cursor_animation_length=0.05
let g:neovide_cursor_trail_length=0.8
let g:neovide_cursor_antialiasing=v:false " i dont need it
let g:neovide_cursor_vfx_mode = "wireframe"
let g:neovide_remember_window_size = v:true
endif
autocmd FileType markdown setlocal spell

84
lua/configs/autocomplete.lua

@ -105,7 +105,7 @@ function M.config()
-- List of all pre-configured LSP servers:
-- github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
require 'lspconfig'.gopls.setup {}
local servers = { 'ccls', 'rust_analyzer', 'pyright', 'sumneko_lua' }
local servers = { 'ccls', 'rust_analyzer', 'pylsp', 'sumneko_lua' }
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = on_attach
@ -127,21 +127,73 @@ function M.config()
end,
})
local lspkind = require('lspkind')
cmp.setup {
formatting = {
format = lspkind.cmp_format({
mode = 'symbol', -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
-- The function below will be called before any actual modifications from lspkind
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
before = function(_, vim_item)
return vim_item
end
})
}
}
local saga = require 'lspsaga'
-- change the lsp symbol kind
--local kind = require('lspsaga.lspkind')
--kind[type_number][2] = icon -- see lua/lspsaga/lspkind.lua
-- use default config
saga.init_lsp_saga({
border_style = "single",
saga_winblend = 0,
move_in_saga = { prev = '<C-p>',next = '<C-n>'},
diagnostic_header = { "", "", "", "" },
show_diagnostic_source = true,
diagnostic_source_bracket = {},
max_preview_lines = 10,
code_action_icon = "",
code_action_num_shortcut = true,
code_action_lightbulb = {
enable = true,
sign = true,
enable_in_insert = true,
sign_priority = 20,
virtual_text = true,
},
finder_icons = {
def = '',
ref = '',
link = '',
},
finder_request_timeout = 1500,
finder_action_keys = {
open = "o",
vsplit = "s",
split = "i",
tabe = "t",
quit = "q",
scroll_down = "<C-f>",
scroll_up = "<C-b>", -- quit can be a table
},
code_action_keys = {
quit = "q",
exec = "<CR>",
},
rename_action_quit = "q",
rename_in_select = true,
definition_preview_icon = "",
-- show symbols in winbar must nightly
symbol_in_winbar = {
in_custom = false,
enable = false,
separator = '',
show_file = true,
click_support = false,
},
show_outline = {
win_position = 'right',
win_with = '',
win_width = 30,
auto_enter = true,
auto_preview = true,
virt_text = '',
jump_key = 'o',
auto_refresh = true,
},
server_filetype_map = {},
})
end

2
lua/core/init.lua

@ -18,6 +18,7 @@ vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
require("core.keymaps")
--require("core.dvorak") -- delete this line if you don't like using DVORAK
require("core.plugins")
-- disable some useless standard plugins to save startup time
-- these features have been better covered by plugins
@ -51,3 +52,4 @@ require("configs.git").config()
require("configs.bufferline").config()
require("configs.grammar").config()

19
lua/core/keymaps.lua

@ -1,7 +1,9 @@
vim.g.mapleader = ';'
-- keymaps
vim.keymap.set('i', '<C-s>', '<esc>')
vim.keymap.set('i', '<C-g>', '<esc>')
vim.keymap.set('i', '<C-;>', '::') -- for C++ and Rust
vim.keymap.set('n', '\\', ':')
-- f: file tree
vim.keymap.set('n', '<F3>', ':NvimTreeToggle<cr>')
vim.keymap.set('n', '<leader>ft', ':NvimTreeToggle<cr>')
@ -47,6 +49,7 @@ vim.keymap.set('n', '<leader>sw', '/\\<lt>\\><left><left>')
-- l: general
-- g: goto
-- w: workspace
-- c: lsp saga
vim.keymap.set('n', '<leader>le', vim.diagnostic.open_float)
vim.keymap.set('n', '<leader>lq', vim.diagnostic.setloclist)
vim.keymap.set('n', '<leader>lk', vim.lsp.buf.hover)
@ -68,10 +71,19 @@ vim.keymap.set('n', '<leader>gr', vim.lsp.buf.references)
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder)
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder)
vim.keymap.set('n', '<leader>wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end)
vim.keymap.set("n", "<leader>ca", ':Lspsaga code_action<cr>')
vim.keymap.set("n", "<leader>cf", ':Lspsaga lsp_finder<cr>')
vim.keymap.set("n", "<leader>cr", ':Lspsaga rename<cr>')
vim.keymap.set("n", "<leader>cp", ':Lspsaga preview_definition<cr>')
vim.keymap.set("n", "<leader>el", ':Lspsaga show_line_diagnostics<cr>')
vim.keymap.set("n", "<leader>ew", ':Lspsaga show_cursor_diagnostics<cr>')
vim.keymap.set("n", "<leader>en", ':Lspsaga diagnostic_jump_next<cr>')
vim.keymap.set("n", "<leader>ep", ':Lspsaga diagnostic_jump_prev<cr>')
-- t: terminal
vim.keymap.set('n', '<leader>tt', ':FloatermToggle<cr>')
vim.keymap.set('n', '<f2>', ':FloatermToggle<cr>')
vim.keymap.set('t', '<f2>', '<c-\\><c-n>:FloatermToggle<return>')
vim.keymap.set('n', '<f5>', ':FloatermToggle<cr>')
vim.keymap.set('t', '<f5>', '<c-\\><c-n>:FloatermToggle<return>')
vim.keymap.set('n', '<leader>tn', ':FloatermNew<cr>')
-- h: git
vim.keymap.set('n', '<leader>hu', ':Gitsigns undo_stage_hunk<cr>')
@ -82,4 +94,3 @@ vim.keymap.set('n', '<leader>hR', ':Gitsigns reset_buffer')
vim.keymap.set('n', '<leader>hb', ':Gitsigns blame_line<cr>')
vim.keymap.set('n', '<leader>hd', ':Gitsigns diffthis<cr>')
vim.keymap.set('n', '<leader>hs', ':<C-U>Gitsigns select_hunk<CR>')

3
lua/core/plugins.lua

@ -26,6 +26,7 @@ return require('packer').startup(function()
use "rebelot/kanagawa.nvim"
use 'NLKNguyen/papercolor-theme'
use 'liuchengxu/space-vim-dark'
use 'sainnhe/edge'
-- file tree
use {
@ -35,6 +36,7 @@ return require('packer').startup(function()
-- language
use 'neovim/nvim-lspconfig'
use 'glepnir/lspsaga.nvim'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path'
@ -42,7 +44,6 @@ return require('packer').startup(function()
use 'hrsh7th/nvim-cmp'
use 'L3MON4D3/LuaSnip'
use 'nvim-treesitter/nvim-treesitter'
use 'onsails/lspkind-nvim'
-- git
use {

10
lua/core/theme.lua

@ -21,8 +21,8 @@
--vim.cmd('colorscheme sonokai')
-- space vim dark
vim.g.space_vim_dark_background = 234 -- 234 (darkest) ~ 238 (lightest)
vim.cmd("colorscheme space-vim-dark");
-- vim.g.space_vim_dark_background = 234 -- 234 (darkest) ~ 238 (lightest)
-- vim.cmd("colorscheme space-vim-dark");
-- kanagwa
-- Default options:
@ -44,3 +44,9 @@ vim.cmd("colorscheme space-vim-dark");
--})
--vim.cmd("colorscheme kanagawa")
-- edge
--vim.g.edge_style = 'aura' -- neon, aura
vim.g.edge_better_performance = 1
vim.cmd("colorscheme edge")
vim.cmd("set background=dark")

Loading…
Cancel
Save