From 089e3ec0eba2179646a78525b2fb9f43e68b0085 Mon Sep 17 00:00:00 2001 From: pgfm Date: Sat, 16 Jul 2022 21:18:28 -0500 Subject: [PATCH] Fixing nvim-cmp, adding Racket support, etc. --- .config/nvim/lua/keymap.lua | 2 +- .config/nvim/lua/packer_init.lua | 16 +++++++++++++++- .config/nvim/lua/plugins/cmp.lua | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.config/nvim/lua/keymap.lua b/.config/nvim/lua/keymap.lua index 9f391fa..fd6b692 100644 --- a/.config/nvim/lua/keymap.lua +++ b/.config/nvim/lua/keymap.lua @@ -12,6 +12,7 @@ end -- Change leader to a comma vim.g.mapleader = ',' +vim.g.maplocalleader = ' ' ----------------------------------------------------------- -- General @@ -130,6 +131,5 @@ map('n', 'D', 'lua vim.lsp.buf.type_definition()') map('n', 'rn', 'lua vim.lsp.buf.rename()') map('n', 'ca', 'lua vim.lsp.buf.code_action()') map('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()') -map('n', 'e', 'lua vim.lsp.diagnostic.open_float()') map('n', '[c', 'lua vim.diagnostic.goto_prev { wrap = false }') map('n', ']c', 'lua vim.diagnostic.goto_next { wrap = false }') diff --git a/.config/nvim/lua/packer_init.lua b/.config/nvim/lua/packer_init.lua index a713625..3581d8b 100644 --- a/.config/nvim/lua/packer_init.lua +++ b/.config/nvim/lua/packer_init.lua @@ -67,13 +67,18 @@ return require('packer').startup(function(use) -- Neovim-native LSP Implementation use 'neovim/nvim-lspconfig' + -- Snippet engine is REQUIRED for nvim-cmp. + use 'L3MON4D3/LuaSnip' + -- nvim-cmp - completion plugin, used for LSP and Metals use { 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-nvim-lsp', '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 } + -- Racket support + use 'benknoble/vim-racket' + + -- Conjure: Supports all Lisps that I work with. + use { + 'Olical/conjure', + ft = { 'rkt', 'racket' } + } + end) diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 345500d..527fdf7 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -1,13 +1,21 @@ local cmp = require('cmp') cmp.setup{ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, sources = { { name = 'nvim_lsp' }, + { name = 'luasnip' }, { name = 'path' }, { name = 'buffer', option = { keyword_length = 4 }, }, }, mapping = { - [''] = cmp.mapping.confirm({}), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.complete(), [''] = function(fallback) if cmp.visible() then cmp.select_next_item() @@ -24,3 +32,12 @@ cmp.setup{ end, }, } + -- Setup conjure, only for supported files +cmp.setup.filetype('racket', { + sources = { + { name = 'conjure' }, + { name = 'luasnip' }, + { name = 'path' }, + { name = 'buffer', option = { keyword_length = 4 }, }, + } +})