Fork me on GitHub
#conjure
<
2022-12-18
>
pyrmont18:12:38

I’m playing around with nvim-cmp and cmp-conjure. I’m trying to find the minimum configuration to have docstrings display but am having no luck.

pyrmont18:12:51

In my init.vim file, I have set completeopt=menu,menuone,noselect and then require a minimal nvim-cmp setup file written in Lua. All it has is this:

local cmp = require("cmp")

cmp.setup({
  window = {
    -- completion = cmp.config.window.bordered(),
    -- documentation = cmp.config.window.bordered(),
  },
  mapping = cmp.mapping.preset.insert({
    ["<C-b>"] = cmp.mapping.scroll_docs(-4),
    ["<C-f>"] = cmp.mapping.scroll_docs(4),
    ["<C-Space>"] = cmp.mapping.complete(),
    ["<C-e>"] = cmp.mapping.abort(),
    ["<CR>"] = cmp.mapping.confirm({ select = true }),

    ["<Tab>"] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      elseif has_words_before() then
        cmp.complete()
      else
        fallback()
      end
    end, {
      "i",
      "s",
    }),

    ["<S-Tab>"] = cmp.mapping(function()
      if cmp.visible() then
        cmp.select_prev_item()
      end
    end, {
      "i",
      "s",
    }),
  }),

  sources = cmp.config.sources({
    { name = "conjure" },
  })
})

pyrmont18:12:54

When I’m in a Clojure file with Conjure connected to a running nREPL server, I get the autocomplete menu but no documentation displays for the options as I scroll through them.

pyrmont18:12:17

Am I wrong in thinking this is something I should be able to see with just these plugins and Conjure?

lispyclouds18:12:01

i think you need to add capabilities to the lspconfig status call with the default capabilities. I have this in my conf: https://github.com/lispyclouds/dotfiles/blob/main/nvim/lua/lsp.lua#L41-L45

pyrmont19:12:36

Thanks for the quick reply! That means I need to be running an LSP as well, right? I’m not doing that at present.

lispyclouds19:12:06

yeah this will talk to the lsp to get it, not sure if conjure itself can do it

lispyclouds19:12:35

i think this is an nvim-cmp and lsp thing, not related to conjure

lispyclouds19:12:03

probably its making the vim.buf.lsp.hover call

pyrmont19:12:09

Yeah, I’m curious as to whether Conjure can do it by itself. https://github.com/PaterJason/cmp-conjure/blob/d76e1fe5d724afe604dfa7b4b5ba93f3d3730617/lua/cmp_conjure/init.lua#L58-L60 it looks like Conjure is what returns the information.

lispyclouds19:12:44

yeah i suppose you need to have an nREPL thing running then? not sure how Conjure does its thing but something needs to parse the clojure code

pyrmont19:12:55

Yeah, I have an nREPL server running.

pyrmont19:12:35

And it’s a memory constrained system so I’m trying to limit this to the minimum necessary components. Thanks for your suggestion, though, I’m looking more into the cmp-nvim-lsp plug-in to see if there’s something there 🙂

lispyclouds19:12:31

well the lsp should take less resources 😆 lsp along til you really need the JVM

pyrmont19:12:19

True 😄 In this case, though, I need the nREPL server running so am seeing how much I can leverage that.

pyrmont19:12:52

It feels like it should be able to do everything since all I really want it to display is the docstring and it’s more than able to look that up.

lispyclouds19:12:58

yeah, this is pretty much my limits of understanding of things from a user perspective. yeah conjure should be able to do it, given that it predates lsp

lispyclouds19:12:21

kinda shows how much ive come to take lsp for granted 😅

pyrmont04:12:53

The problem was a consequence of only using nREPL without the CIDER middleware. If I put the following as an alias in my deps.edn then suddenly it all works as expected:

:nrepl {:extra-deps {cider/cider-nrepl  {:mvn/version  "0.29.0"}}
        :main-opts ["-m" "nrepl.cmdline" "--middleware"  "[cider.nrepl/cider-middleware]"]}

1
pyrmont04:12:53

The problem was a consequence of only using nREPL without the CIDER middleware. If I put the following as an alias in my deps.edn then suddenly it all works as expected:

:nrepl {:extra-deps {cider/cider-nrepl  {:mvn/version  "0.29.0"}}
        :main-opts ["-m" "nrepl.cmdline" "--middleware"  "[cider.nrepl/cider-middleware]"]}

1