98 lines
3.9 KiB
Lua
98 lines
3.9 KiB
Lua
--require'lspconfig'.gopls.setup{
|
||
-- on_attach = function()
|
||
-- print("gopls loaded")
|
||
-- -- "n" normal mode
|
||
-- -- map in normal mode, press K to open buf.hover only in the current buffer
|
||
-- vim.keymap.set("n", "K", vim.lsp.buf.hover, {buffer=0})
|
||
-- vim.keymap.set("n", "gd", vim.lsp.buf.definition, {buffer=0})
|
||
-- -- there is a jump list and tag list
|
||
-- -- ctrl+o to go to previous jump entry
|
||
-- -- ctrl+t to go to previous tag entry
|
||
-- vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, {buffer=0})
|
||
-- vim.keymap.set("n", "gi", vim.lsp.buf.implementation, {buffer=0})
|
||
-- vim.keymap.set("n", "<leader>df", vim.diagnostic.goto_next, {buffer=0})
|
||
--
|
||
-- end,
|
||
--}
|
||
--
|
||
|
||
local o = vim.o
|
||
local wo = vim.wo
|
||
local bo = vim.bo
|
||
|
||
-- global options
|
||
-- +- current line on left side
|
||
o.relativenumber = true
|
||
-- also show current exact line number
|
||
o.number = true
|
||
o.signcolumn = "number"
|
||
-- bright colors
|
||
o.bg = "dark"
|
||
-- switch between buffers without saving
|
||
o.hidden = true
|
||
-- look cool
|
||
o.listchars = "tab:▶ ,trail:☲,extends:❯,precedes:❮,nbsp:¬,eol:⤦"
|
||
-- show hidden chars
|
||
o.list = true
|
||
-- kill the rat
|
||
o.mouse = ""
|
||
-- show chars as search is typed
|
||
o.incsearch = true
|
||
-- all lower searches match all cases, any number of caps forces case sensitive
|
||
o.ignorecase = true
|
||
o.smartcase = true
|
||
-- dont show intro text and do some abbreviations
|
||
o.shortmess = "fiIc"
|
||
o.syntax = "enable"
|
||
--
|
||
-- Set completeopt to have a better completion experience
|
||
-- :help completeopt
|
||
-- menuone: popup even when there's only one match
|
||
-- noinsert: Do not insert text until a selection is made
|
||
-- noselect: Do not select, force user to select one from the menu
|
||
o.completeopt = "menuone,noinsert,noselect"
|
||
|
||
|
||
local map = vim.api.nvim_set_keymap
|
||
|
||
options = { silent = true }
|
||
map('n', '<esc><esc>', ':nohlsearch<cr>:echo ""<cr>', options)
|
||
map('n', '<F2>', ":set nolist nonumber norelativenumber signcolumn=no<cr>", options)
|
||
map('n', '<F3>', ":set list number relativenumber signcolumn=number<cr>", options)
|
||
|
||
-- vim.cmd('colorscheme papaya')
|
||
o.termguicolors = true
|
||
|
||
-- " use <Tab> as trigger keys
|
||
-- imap <Tab> <Plug>(completion_smart_tab)
|
||
-- imap <S-Tab> <Plug>(completion_smart_s_tab)
|
||
|
||
-- use tab to scroll completion
|
||
vim.api.nvim_set_keymap('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true})
|
||
vim.api.nvim_set_keymap('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true})
|
||
|
||
-- " Code navigation shortcuts
|
||
options = { silent = true }
|
||
vim.api.nvim_set_keymap('n', '<c-J>', ':lua vim.lsp.buf.definition()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', 'K', ':lua vim.lsp.buf.hover()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', 'gD', ':lua vim.lsp.buf.implementation()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', '<c-k>', ':lua vim.lsp.buf.signature_help()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', '1gD', ':lua vim.lsp.buf.type_definition()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', 'gr', ':lua vim.lsp.buf.references()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', 'g0', ':lua vim.lsp.buf.document_symbol()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', 'gW', ':lua vim.lsp.buf.workspace_symbol()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', 'gd', ':lua vim.lsp.buf.declaration()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', 'ga', ':lua vim.lsp.buf.code_action()<CR>', options)
|
||
-- " Goto previous/next diagnostic warning/error
|
||
vim.api.nvim_set_keymap('n', 'g]', ':lua vim.lsp.diagnostic.goto_next()<CR>', options)
|
||
vim.api.nvim_set_keymap('n', 'g[', ':lua vim.lsp.diagnostic.goto_prev()<CR>', options)
|
||
|
||
o.updatetime = 5000
|
||
-- " Show diagnostic popup on cursor hold
|
||
vim.api.nvim_command('autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics()')
|
||
-- type hints!
|
||
-- vim.api.nvim_command([[
|
||
-- autocmd CursorHold,CursorMoved,InsertLeave,BufEnter,BufWinEnter,TabEnter,BufWritePost * lua require'lsp_extensions'.inlay_hints{ prefix = '', highlight = "Comment", enabled = {"TypeHint", "ChainingHint", "ParameterHint"}, prefix = " ⇋ ", }
|
||
-- ]])
|
||
|