Created
September 12, 2021 18:31
-
-
Save PaterJason/f3192d26e6d70d38702c5ca3016cd496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return require'packer'.startup(function(use) | |
use'wbthomason/packer.nvim' | |
-- Parens | |
use'tpope/vim-surround' | |
use{ | |
'guns/vim-sexp', | |
requires = {'tpope/vim-sexp-mappings-for-regular-people'}, | |
} | |
use{ | |
'hrsh7th/nvim-cmp', | |
requires = { | |
'PaterJason/cmp-conjure', | |
'hrsh7th/cmp-nvim-lsp', | |
}, | |
config = function() | |
require'cmp'.setup{ | |
sources = { | |
{name = 'conjure'}, | |
{name = 'nvim_lsp'}, | |
}, | |
} | |
end, | |
} | |
-- LSP | |
use{ | |
'neovim/nvim-lspconfig', | |
config = function() | |
local keymap_opts = {noremap = true} | |
-- Execute Clojure refactor commands | |
function _G.clj_lsp_cmd (cmd, prompt) | |
local params = vim.lsp.util.make_position_params() | |
local args = {params.textDocument.uri , params.position.line, params.position.character} | |
if prompt then | |
local input = vim.fn.input(prompt) | |
table.insert(args, input) | |
end | |
vim.lsp.buf.execute_command({ | |
command = cmd, | |
arguments = args, | |
}) | |
end | |
-- Refactor keybindings | |
local clj_map = function(bufnr) | |
local mappings = { | |
cc = [['cycle-coll']], | |
th = [['thread-first']], | |
tt = [['thread-last']], | |
tf = [['thread-first-all']], | |
tl = [['thread-last-all']], | |
uw = [['unwind-thread']], | |
ua = [['unwind-all']], | |
ml = [['move-to-let', 'Binding name: ']], | |
il = [['introduce-let', 'Binding name: ']], | |
el = [['expand-let']], | |
am = [['add-missing-libspec']], | |
cn = [['clean-ns']], | |
cp = [['cycle-privacy']], | |
is = [['inline-symbol']], | |
ef = [['extract-function', 'Function name: ']], | |
ai = [['add-import-to-namespace', 'Import name: ']], | |
} | |
for keys, args in pairs(mappings) do | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>r' .. keys, '<cmd>call v:lua.clj_lsp_cmd(' .. args ..')<CR>', keymap_opts) | |
end | |
end | |
-- Add cmp capabilities | |
local capabilities = vim.lsp.protocol.make_client_capabilities() | |
capabilities = require'cmp_nvim_lsp'.update_capabilities(capabilities) | |
-- Run when language server attaches to buffer | |
local custom_lsp_attach = function(client, bufnr) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', keymap_opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', keymap_opts) | |
-- ... and other keymappings for LSP | |
end | |
require'lspconfig'.clojure_lsp.setup{ | |
on_attach = function(client, bufnr) | |
clj_map(bufnr) | |
custom_lsp_attach(client, bufnr) | |
end, | |
capabilities = capabilities, | |
} | |
end, | |
} | |
-- Telescope | |
use{ | |
'nvim-telescope/telescope.nvim', | |
requires = { | |
'nvim-lua/popup.nvim', | |
'nvim-lua/plenary.nvim', | |
}, | |
} | |
-- Clojure | |
use{ | |
'Olical/conjure', | |
config = function() | |
vim.g['conjure#mapping#doc_word'] = 'K' | |
end, | |
} | |
use'clojure-vim/vim-jack-in' | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment