Fork me on GitHub
#conjure
<
2023-01-11
>
The Continium12:01:11

Hi - I’ve started to use https://github.com/AckslD/nvim-FeMaco.lua with conjure to evaluate in markdown code blocks with all the normal lsp+diags+completion for that language. I’m currently using for clojure and python at the moment; Anyone else using/configured this ?

Olical13:01:44

That's REALLY cool, thanks for sharing. Exactly what I hoped someone would make one day so Conjure would just work inside markdown files.

The Continium13:01:53

It’s really quite cool where you can have different languages blocks and evaluate e.g. python in one and then clojure in another. With the floating code block window I don’t get a HUD. Maybe you can give it a spin and see if there are some improvements to make them work better together ?

Martynas Maciulevičius14:01:07

Can this run in my init.vim so that I could edit Lua inside of it?

lua << EOF
 -- 
EOF

The Continium14:01:13

yes - just tried this and conure evals as expected

lua << EOF
print("lua")
EOF

Martynas Maciulevičius14:01:32

I think my treesitter config may be off 😕 I'll need to find how to configure it properly. For me running of that command doesn't give neither the popup, neither the error :thinking_face:

The Continium14:01:15

I also have it working in split window rather than floating so that you get the HUD as well.

require('femaco').setup({
  -- should prepare a new buffer and return the winid
  -- by default opens a floating window
  -- provide a different callback to change this behaviour
  -- @param opts: the return value from float_opts
  prepare_buffer = function(opts)
		local bufnr = vim.api.nvim_create_buf(false, false)
		vim.cmd'split'
		vim.cmd(string.format('buffer %d', bufnr))
		return vim.api.nvim_get_current_win()
    -- local buf = vim.api.nvim_create_buf(false, false)
    -- return vim.api.nvim_open_win(buf, true, opts)
  end,
  -- should return options passed to nvim_open_win
  -- @param code_block: data about the code-block with the keys
  --   * range
  --   * lines
  --   * lang
  float_opts = function(code_block)
    return {
    }
  end,
  -- return filetype to use for a given lang
  -- lang can be nil
  ft_from_lang = function(lang)
    return lang
  end,
  -- what to do after opening the float
  post_open_float = function(winnr)
    vim.wo.signcolumn = 'no'
  end,
  -- create the path to a temporary file
  create_tmp_filepath = function(filetype)
    return os.tmpname()
  end,
  -- if a newline should always be used, useful for multiline injections
  -- which separators needs to be on separate lines such as markdown, neorg etc
  -- @param base_filetype: The filetype which FeMaco is called from, not the
  -- filetype of the injected language (this is the current buffer so you can
  -- get it from vim.bo.filetyp).
  ensure_newline = function(base_filetype)
    return false
  end,
})

Martynas Maciulevičius14:01:50

I can't run the basic example. Something is broken in my config.

require'nvim-treesitter.configs'.setup {
}
require('femaco').setup()
I don't know what it is. I also have installed the markdown treesitter module and so on. I don't know.

Martynas Maciulevičius15:01:25

I think it's too much 😄 I have this config:

require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true,
    -- 
    disable = { "clojure" },
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    -- additional_vim_regex_highlighting = true,
  },

--  -- require"nvim-treesitter.highlight".set_custom_captures {
--  --   -- Highlight the @foo.bar capture group with the "Identifier" highlight group.
--  --   --["function.macro"] = "Identifier",
--  --   --["keyword.function"] = "TSKeywordFunction",
--  --   --["text.strong"] = "TSText",
--
--  --   -- doesn't work:
--  --   --["clojureNs"]    = "clojureCharacter",
--  --   --["clojureNsSep"] = "Normal"
--  -- }
}
I don't want to specify every possible server and dependency. It's too much.