Fixing nvim-cmp, adding Racket support, etc.

This commit is contained in:
pgfm 2022-07-16 21:18:28 -05:00
parent 35dd6c19c9
commit 089e3ec0eb
3 changed files with 34 additions and 3 deletions

View file

@ -12,6 +12,7 @@ end
-- Change leader to a comma -- Change leader to a comma
vim.g.mapleader = ',' vim.g.mapleader = ','
vim.g.maplocalleader = ' '
----------------------------------------------------------- -----------------------------------------------------------
-- General -- General
@ -130,6 +131,5 @@ map('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
map('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>') map('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>')
map('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>') map('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>')
map('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>') map('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>')
map('n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.open_float()<CR>')
map('n', '[c', '<cmd>lua vim.diagnostic.goto_prev { wrap = false }<CR>') map('n', '[c', '<cmd>lua vim.diagnostic.goto_prev { wrap = false }<CR>')
map('n', ']c', '<cmd>lua vim.diagnostic.goto_next { wrap = false }<CR>') map('n', ']c', '<cmd>lua vim.diagnostic.goto_next { wrap = false }<CR>')

View file

@ -67,13 +67,18 @@ return require('packer').startup(function(use)
-- Neovim-native LSP Implementation -- Neovim-native LSP Implementation
use 'neovim/nvim-lspconfig' use 'neovim/nvim-lspconfig'
-- Snippet engine is REQUIRED for nvim-cmp.
use 'L3MON4D3/LuaSnip'
-- nvim-cmp - completion plugin, used for LSP and Metals -- nvim-cmp - completion plugin, used for LSP and Metals
use { use {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
requires = { requires = {
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path', 'hrsh7th/cmp-path',
'hrsh7th/cmp-buffer' 'hrsh7th/cmp-buffer',
'saadparwaiz1/cmp_luasnip'
--'PaterJason/cmp-conjure'
} }
} }
@ -139,4 +144,13 @@ return require('packer').startup(function(use)
end end
} }
-- Racket support
use 'benknoble/vim-racket'
-- Conjure: Supports all Lisps that I work with.
use {
'Olical/conjure',
ft = { 'rkt', 'racket' }
}
end) end)

View file

@ -1,13 +1,21 @@
local cmp = require('cmp') local cmp = require('cmp')
cmp.setup{ cmp.setup{
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
sources = { sources = {
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' }, { name = 'path' },
{ name = 'buffer', option = { keyword_length = 4 }, }, { name = 'buffer', option = { keyword_length = 4 }, },
}, },
mapping = { mapping = {
['<CR>'] = cmp.mapping.confirm({}), ['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-Space>'] = cmp.mapping.complete(),
['<Tab>'] = function(fallback) ['<Tab>'] = function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
@ -24,3 +32,12 @@ cmp.setup{
end, end,
}, },
} }
-- Setup conjure, only for supported files
cmp.setup.filetype('racket', {
sources = {
{ name = 'conjure' },
{ name = 'luasnip' },
{ name = 'path' },
{ name = 'buffer', option = { keyword_length = 4 }, },
}
})