mirror of
https://github.com/ksyasuda/rice.git
synced 2024-10-28 09:04:10 -07:00
update nvim
This commit is contained in:
parent
997cd34645
commit
9b80bee1d5
@ -1,7 +1,7 @@
|
||||
syntax enable
|
||||
filetype plugin on
|
||||
set noshowmode "disable default vim insert text at bottom
|
||||
set laststatus=2
|
||||
set laststatus=3
|
||||
set number
|
||||
set colorcolumn=80
|
||||
set tw=80
|
||||
@ -79,6 +79,8 @@ if has('nvim')
|
||||
Plug 'nvim-lua/plenary.nvim'
|
||||
Plug 'nvim-lua/popup.nvim'
|
||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||
" Plug 'zbirenbaum/copilot.lua'
|
||||
" Plug 'zbirenbaum/copilot-cmp'
|
||||
" Plug 'nvim-telescope/telescope.nvim'
|
||||
|
||||
" Plug 'TimUntersberger/neogit'
|
||||
@ -153,6 +155,7 @@ if has('nvim')
|
||||
source ~/.config/nvim/plugin-confs/whichkey.lua
|
||||
|
||||
source ~/.config/nvim/plugin-confs/code_actions.lua
|
||||
" source ~/.config/nvim/plugin-confs/copilot.lua
|
||||
source ~/.config/nvim/plugin-confs/goto-preview.lua
|
||||
source ~/.config/nvim/plugin-confs/lsp-kind.lua
|
||||
source ~/.config/nvim/plugin-confs/lsp-signature.lua
|
||||
|
@ -5,10 +5,10 @@ nmap <F5> :!
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
" for toggling/hiding the vsplit-term
|
||||
" for toggling/hiding the split-term
|
||||
tnoremap <C-T> <C-\><C-n>:FloatermToggle floatingterm<CR>
|
||||
tnoremap <Esc> <C-\><C-n>
|
||||
tnoremap <leader>tt <C-\><C-N>:FloatermToggle vsplit-term<CR>
|
||||
tnoremap <leader>tt <C-\><C-N>:FloatermToggle split-term<CR>
|
||||
|
||||
nmap <C-J> :bnext<CR>
|
||||
nmap <C-K> :bprev<CR>
|
||||
@ -91,9 +91,10 @@ nmap <leader>n :NvimTreeToggle<CR>
|
||||
|
||||
nmap <leader>ob :FloatermNew --title=bpytop --opener=vsplit bpytop<CR>
|
||||
nmap <leader>od :FloatermNew --title=lazydocker --opener=vsplit lazydocker<CR>
|
||||
nmap <leader>oh :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=split --position=botright --height=0.45<CR>
|
||||
nmap <leader>on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp<CR>
|
||||
nmap <leader>or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD"<CR>
|
||||
nmap <leader>ot :FloatermNew --title=floaterm --name=vsplit-term --opener=edit --wintype=vsplit --position=botright --width=0.5<CR>
|
||||
nmap <leader>ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5<CR>
|
||||
|
||||
nmap <leader>r :NvimTreeRefresh<CR>
|
||||
|
||||
@ -107,7 +108,7 @@ nmap <leader>s/ :History/<CR>
|
||||
|
||||
nnoremap <silent> <Leader>tc :DashboardChangeColorscheme<CR>
|
||||
nmap <leader>to :SymbolsOutline<CR>
|
||||
nmap <leader>tt :FloatermToggle vsplit-term<CR>
|
||||
nmap <leader>tt :FloatermToggle split-term<CR>
|
||||
|
||||
nmap <leader>wa :lua vim.lsp.buf.add_workspace_folder()<CR>
|
||||
nmap <leader>wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>
|
||||
|
@ -1,4 +1,4 @@
|
||||
local opts = { noremap=true, silent=true }
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||
@ -7,38 +7,38 @@ vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<C
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
-- set in ~/.config/nvim/keybindings.vim
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-s>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
-- highlighting things under cursor
|
||||
-- if client.resolved_capabilities.document_highlight then
|
||||
-- vim.cmd [[
|
||||
-- hi! LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
|
||||
-- hi! LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
|
||||
-- hi! LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
|
||||
-- augroup lsp_document_highlight
|
||||
-- autocmd! * <buffer>
|
||||
-- autocmd! CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||
-- autocmd! CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||
-- augroup END
|
||||
-- ]]
|
||||
-- end
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
-- set in ~/.config/nvim/keybindings.vim
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-s>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
-- highlighting things under cursor
|
||||
-- if client.resolved_capabilities.document_highlight then
|
||||
-- vim.cmd [[
|
||||
-- hi! LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
|
||||
-- hi! LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
|
||||
-- hi! LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
|
||||
-- augroup lsp_document_highlight
|
||||
-- autocmd! * <buffer>
|
||||
-- autocmd! CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||
-- autocmd! CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||
-- augroup END
|
||||
-- ]]
|
||||
-- end
|
||||
end
|
||||
|
||||
vim.cmd [[autocmd! ColorScheme * highlight NormalFloat guibg=#1f2335]]
|
||||
@ -60,19 +60,19 @@ vim.cmd [[autocmd! ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335
|
||||
-- rounded
|
||||
|
||||
local border = {
|
||||
{"╭", "FloatBorder"},
|
||||
{"─", "FloatBorder"},
|
||||
{"╮", "FloatBorder"},
|
||||
{"│", "FloatBorder"},
|
||||
{"╯", "FloatBorder"},
|
||||
{"─", "FloatBorder"},
|
||||
{"╰", "FloatBorder"},
|
||||
{"│", "FloatBorder"},
|
||||
{ "╭", "FloatBorder" },
|
||||
{ "─", "FloatBorder" },
|
||||
{ "╮", "FloatBorder" },
|
||||
{ "│", "FloatBorder" },
|
||||
{ "╯", "FloatBorder" },
|
||||
{ "─", "FloatBorder" },
|
||||
{ "╰", "FloatBorder" },
|
||||
{ "│", "FloatBorder" },
|
||||
}
|
||||
|
||||
local handlers = {
|
||||
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border}),
|
||||
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border }),
|
||||
local handlers = {
|
||||
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }),
|
||||
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }),
|
||||
}
|
||||
|
||||
local DEFAULT_SETTINGS = {
|
||||
@ -110,7 +110,7 @@ local DEFAULT_SETTINGS = {
|
||||
install_args = {},
|
||||
},
|
||||
on_attach = on_attach,
|
||||
handlers=handlers,
|
||||
handlers = handlers,
|
||||
|
||||
-- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when
|
||||
-- debugging issues with server installations.
|
||||
@ -122,36 +122,36 @@ local DEFAULT_SETTINGS = {
|
||||
}
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
underline = false,
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
underline = false,
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
|
||||
function PrintDiagnostics(opts, bufnr, line_nr, client_id)
|
||||
bufnr = bufnr or 0
|
||||
line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1)
|
||||
opts = opts or {['lnum'] = line_nr}
|
||||
bufnr = bufnr or 0
|
||||
line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1)
|
||||
opts = opts or { ['lnum'] = line_nr }
|
||||
|
||||
local line_diagnostics = vim.diagnostic.get(bufnr, opts)
|
||||
if vim.tbl_isempty(line_diagnostics) then return end
|
||||
local line_diagnostics = vim.diagnostic.get(bufnr, opts)
|
||||
if vim.tbl_isempty(line_diagnostics) then return end
|
||||
|
||||
local diagnostic_message = ""
|
||||
for i, diagnostic in ipairs(line_diagnostics) do
|
||||
diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "")
|
||||
print(diagnostic_message)
|
||||
if i ~= #line_diagnostics then
|
||||
diagnostic_message = diagnostic_message .. "\n"
|
||||
local diagnostic_message = ""
|
||||
for i, diagnostic in ipairs(line_diagnostics) do
|
||||
diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "")
|
||||
print(diagnostic_message)
|
||||
if i ~= #line_diagnostics then
|
||||
diagnostic_message = diagnostic_message .. "\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.api.nvim_echo({{diagnostic_message, "Normal"}}, false, {})
|
||||
vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {})
|
||||
end
|
||||
|
||||
-- vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]]
|
||||
@ -176,13 +176,13 @@ end)
|
||||
|
||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
-- map buffer local keybindings when the language server attaches
|
||||
local servers = { 'pyright', 'bashls', 'vimls', 'yamlls', 'dockerls', 'html', 'sumneko_lua', 'dotls', 'rust_analyzer', 'clangd' }
|
||||
local servers = { 'pyright', 'bashls', 'vimls', 'yamlls', 'dockerls', 'html', 'sumneko_lua', 'dotls', 'rust_analyzer', 'clangd', 'ansiblels' }
|
||||
for _, lsp in pairs(servers) do
|
||||
require('lspconfig')[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
-- This will be the default in neovim 0.7+
|
||||
debounce_text_changes = 150,
|
||||
require('lspconfig')[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
-- This will be the default in neovim 0.7+
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -13,35 +13,36 @@ require("null-ls").setup({
|
||||
end
|
||||
end,
|
||||
sources = {
|
||||
require("null-ls").builtins.completion.spell,
|
||||
require("null-ls").builtins.completion.luasnip,
|
||||
require("null-ls").builtins.code_actions.gitsigns,
|
||||
require("null-ls").builtins.code_actions.shellcheck,
|
||||
require("null-ls").builtins.diagnostics.cppcheck,
|
||||
require("null-ls").builtins.diagnostics.gitlint,
|
||||
require("null-ls").builtins.diagnostics.jsonlint,
|
||||
null_ls.builtins.completion.spell,
|
||||
null_ls.builtins.completion.luasnip,
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.code_actions.shellcheck,
|
||||
null_ls.builtins.diagnostics.cppcheck,
|
||||
null_ls.builtins.diagnostics.gitlint,
|
||||
null_ls.builtins.diagnostics.jsonlint,
|
||||
-- require("null-ls").builtins.diagnostics.luacheck,
|
||||
require("null-ls").builtins.diagnostics.markdownlint,
|
||||
require("null-ls").builtins.diagnostics.pylint,
|
||||
require("null-ls").builtins.diagnostics.pydocstyle.with({
|
||||
null_ls.builtins.diagnostics.markdownlint,
|
||||
null_ls.builtins.diagnostics.pylint,
|
||||
null_ls.builtins.diagnostics.pydocstyle.with({
|
||||
extra_args = { "--config=$ROOT/setup.cfg" }
|
||||
}),
|
||||
require("null-ls").builtins.diagnostics.vint,
|
||||
require("null-ls").builtins.formatting.json_tool,
|
||||
null_ls.builtins.diagnostics.vint,
|
||||
null_ls.builtins.diagnostics.shellcheck.with({
|
||||
extra_args = { "-s", "bash", "-o", "add-default-case, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables" }
|
||||
}),
|
||||
null_ls.builtins.diagnostics.ansiblelint,
|
||||
null_ls.builtins.formatting.json_tool,
|
||||
-- require("null-ls").builtins.formatting.lua_format,
|
||||
require("null-ls").builtins.formatting.markdownlint,
|
||||
require("null-ls").builtins.formatting.prettier,
|
||||
null_ls.builtins.formatting.markdownlint,
|
||||
null_ls.builtins.formatting.prettier,
|
||||
-- handled by lsp server
|
||||
-- require("null-ls").builtins.formatting.rustfmt,
|
||||
require("null-ls").builtins.formatting.shfmt.with({
|
||||
filetypes = {"sh", "bash"},
|
||||
null_ls.builtins.formatting.shfmt.with({
|
||||
filetypes = { "sh", "bash" },
|
||||
extra_args = { "-i", "0", "-ci", "-sr" }
|
||||
}),
|
||||
require("null-ls").builtins.diagnostics.shellcheck.with({
|
||||
extra_args = { "-s", "bash", "-o", "check-extra-masked-returns, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables" }
|
||||
}),
|
||||
require("null-ls").builtins.formatting.black,
|
||||
require("null-ls").builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.black,
|
||||
null_ls.builtins.formatting.isort,
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- Setup nvim-cmp.
|
||||
local cmp = require'cmp'
|
||||
local cmp = require 'cmp'
|
||||
local lspkind = require('lspkind')
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
@ -10,12 +10,12 @@ local luasnip = require 'luasnip'
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
end,
|
||||
expand = function(args)
|
||||
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
end,
|
||||
},
|
||||
capabilities = capabilities,
|
||||
-- mapping = {
|
||||
@ -30,72 +30,74 @@ cmp.setup({
|
||||
-- ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
-- },
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
-- ['<Tab>'] = function(fallback)
|
||||
-- if cmp.visible() then
|
||||
-- cmp.select_next_item()
|
||||
-- elseif luasnip.expand_or_jumpable() then
|
||||
-- luasnip.expand_or_jump()
|
||||
-- else
|
||||
-- fallback()
|
||||
-- end
|
||||
-- end,
|
||||
-- ['<S-Tab>'] = function(fallback)
|
||||
-- if cmp.visible() then
|
||||
-- cmp.select_prev_item()
|
||||
-- elseif luasnip.jumpable(-1) then
|
||||
-- luasnip.jump(-1)
|
||||
-- else
|
||||
-- fallback()
|
||||
-- end
|
||||
-- end,
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
-- ['<Tab>'] = function(fallback)
|
||||
-- if cmp.visible() then
|
||||
-- cmp.select_next_item()
|
||||
-- elseif luasnip.expand_or_jumpable() then
|
||||
-- luasnip.expand_or_jump()
|
||||
-- else
|
||||
-- fallback()
|
||||
-- end
|
||||
-- end,
|
||||
-- ['<S-Tab>'] = function(fallback)
|
||||
-- if cmp.visible() then
|
||||
-- cmp.select_prev_item()
|
||||
-- elseif luasnip.jumpable(-1) then
|
||||
-- luasnip.jump(-1)
|
||||
-- else
|
||||
-- fallback()
|
||||
-- end
|
||||
-- end,
|
||||
},
|
||||
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)
|
||||
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 (entry, vim_item)
|
||||
-- ...
|
||||
-- return vim_item
|
||||
-- end
|
||||
})
|
||||
-- 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 (entry, vim_item)
|
||||
-- ...
|
||||
-- return vim_item
|
||||
-- end
|
||||
})
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||
-- { name = 'snippy' }, -- For snippy users.
|
||||
{ name = "copilot", group_index = 2 },
|
||||
{ name = 'nvim_lsp', group_index = 2 },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
{ name = "path", group_index = 2 },
|
||||
{ name = 'luasnip', group_index = 2 }, -- For luasnip users.
|
||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||
-- { name = 'snippy' }, -- For snippy users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
-- Setup lspconfig.
|
||||
-- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||
-- require('lspconfig')['bashls'].setup {
|
||||
-- capabilities = capabilities
|
||||
-- }
|
||||
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||
local lspconfig = require('lspconfig')
|
||||
local servers = { 'bashls', 'pyright', 'sqlls', 'jsonls', 'yamlls', 'vimls', 'dotls', 'dockerls' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
-- Setup lspconfig.
|
||||
-- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||
-- require('lspconfig')['bashls'].setup {
|
||||
-- capabilities = capabilities
|
||||
-- }
|
||||
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||
local lspconfig = require('lspconfig')
|
||||
local servers = { 'bashls', 'pyright', 'sqlls', 'jsonls', 'yamlls', 'vimls', 'dotls', 'dockerls' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
-- on_attach = my_custom_on_attach,
|
||||
capabilities = capabilities,
|
||||
-- on_attach = my_custom_on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user