Get snippets running
This commit is contained in:
parent
9009d1365f
commit
19f925775a
37
init.lua
37
init.lua
@ -73,12 +73,12 @@ utils.map('n', '<leader>b', '<cmd>Telescope buffers<cr>')
|
|||||||
utils.map('n', '<space>r', '<cmd>Telescope lsp_references<cr>')
|
utils.map('n', '<space>r', '<cmd>Telescope lsp_references<cr>')
|
||||||
utils.map('n', '<C-S-o>', '<cmd>Telescope lsp_document_symbols<cr>')
|
utils.map('n', '<C-S-o>', '<cmd>Telescope lsp_document_symbols<cr>')
|
||||||
-------------------- LSP -----------------------------------
|
-------------------- LSP -----------------------------------
|
||||||
local lsp = require 'lspconfig'
|
local nvim_lsp = require 'lspconfig'
|
||||||
|
|
||||||
-- We use the default settings for ccls and pylsp: the option table can stay empty
|
-- We use the default settings for ccls and pylsp: the option table can stay empty
|
||||||
lsp.ccls.setup {}
|
nvim_lsp.ccls.setup {}
|
||||||
lsp.pyright.setup{}
|
nvim_lsp.pyright.setup{}
|
||||||
lsp.clangd.setup{}
|
nvim_lsp.clangd.setup{}
|
||||||
|
|
||||||
utils.map('n', '<space>,', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>')
|
utils.map('n', '<space>,', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>')
|
||||||
utils.map('n', '<space>;', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>')
|
utils.map('n', '<space>;', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>')
|
||||||
@ -94,6 +94,33 @@ utils.map('n', '<C-t>', '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>')
|
|||||||
|
|
||||||
utils.map('n', '<A-o>', ':ClangdSwitchSourceHeader<CR>')
|
utils.map('n', '<A-o>', ':ClangdSwitchSourceHeader<CR>')
|
||||||
|
|
||||||
|
-- Add additional capabilities supported by nvim-cmp
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities.textDocument.completion.completionItem.documentationFormat = { 'markdown', 'plaintext' }
|
||||||
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
capabilities.textDocument.completion.completionItem.preselectSupport = true
|
||||||
|
capabilities.textDocument.completion.completionItem.insertReplaceSupport = true
|
||||||
|
capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
|
||||||
|
capabilities.textDocument.completion.completionItem.deprecatedSupport = true
|
||||||
|
capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
|
||||||
|
capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } }
|
||||||
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||||
|
properties = {
|
||||||
|
'documentation',
|
||||||
|
'detail',
|
||||||
|
'additionalTextEdits',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||||
|
local servers = { 'clangd', 'pyright', 'rust_analyzer', 'tsserver' }
|
||||||
|
for _, lsp in ipairs(servers) do
|
||||||
|
nvim_lsp[lsp].setup {
|
||||||
|
-- on_attach = my_custom_on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
-------------------- GITSIGNS ------------------------------
|
-------------------- GITSIGNS ------------------------------
|
||||||
-- require('gitsigns').setup()
|
-- require('gitsigns').setup()
|
||||||
-------------------- LIGHTBULB -----------------------------
|
-------------------- LIGHTBULB -----------------------------
|
||||||
@ -132,3 +159,5 @@ require'nvim-treesitter.configs'.setup {
|
|||||||
-- termcolors = {} -- table of colour name strings
|
-- termcolors = {} -- table of colour name strings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
-------------------- LUASNIP -------------------------------
|
||||||
|
require("luasnip.loaders.from_vscode").load()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
local t = function(str)
|
local t = function(str)
|
||||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||||
@ -45,26 +46,28 @@ cmp.setup {
|
|||||||
}),
|
}),
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
if vim.fn.pumvisible() == 1 then
|
if vim.fn.pumvisible() == 1 then
|
||||||
if vim.fn["UltiSnips#CanExpandSnippet"]() == 1 or
|
vim.api.nvim_feedkeys(t("<C-n>"), "n", true)
|
||||||
vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
|
elseif luasnip.expand_or_jumpable() then
|
||||||
return vim.fn.feedkeys(t(
|
vim.api.nvim_feedkeys(t("<Plug>luasnip-expand-or-jump"), "", true)
|
||||||
"<C-R>=UltiSnips#ExpandSnippetOrJump()<CR>"))
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.fn.feedkeys(t("<C-n>"), "n")
|
|
||||||
elseif check_back_space() then
|
|
||||||
vim.fn.feedkeys(t("<tab>"), "n")
|
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, {"i", "s"}),
|
end, {
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
"i",
|
||||||
|
"s",
|
||||||
|
}),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
if vim.fn.pumvisible() == 1 then
|
if vim.fn.pumvisible() == 1 then
|
||||||
vim.fn.feedkeys(t("<C-p>"), "n")
|
vim.api.nvim_feedkeys(t("<C-p>"), "n", true)
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
vim.api.nvim_feedkeys(t("<Plug>luasnip-jump-prev"), "", true)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, {"i", "s"})
|
end, {
|
||||||
|
"i",
|
||||||
|
"s",
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user