Giter Club home page Giter Club logo

Comments (18)

jakewvincent avatar jakewvincent commented on May 16, 2024 1

@trev-dev Just fiddling a little bit with this... you can still add a vimscript file under mkdnflow.nvim/syntax/. I did get a little bit of concealing to work when placed there.

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024 1

Update: Actually it looks like it can be placed in lua. If you have a file called conceal.lua and load it in the setup function (by adding init.conceal = require('mkdnflow.conceal') after load_on_ft[ft], the above conceals will load properly. They have to be wrapped in lua functions of course:

vim.api.nvim_command("call matchadd('Conceal', '\\[\\ \\]', 0, 11, {'conceal': ''})")
vim.api.nvim_command("call matchadd('Conceal', '\\[x\\]', 0, 12, {'conceal': ''})")
vim.api.nvim_command("highlight Conceal ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE")
vim.api.nvim_win_set_option(0, 'conceallevel', 1)

from mkdnflow.nvim.

trev-dev avatar trev-dev commented on May 16, 2024 1

I am! Would much rather own my original offer to help out than drop it. The collaborative effort has been a really nice touch. Thanks for stepping in with me.

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024 1

Added in commit 23c22f1; currently testing in dev branch.

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024

I agree that the concealing that Vimwiki and others do would be nice, especially since markdown-style links can look overly long. I'll try to look into this soon and will comment again here if/when I have something to be tested.

from mkdnflow.nvim.

trev-dev avatar trev-dev commented on May 16, 2024

Thanks Jake. I would not mind taking a stab at this if you're open to it. I looked up :help conceal right after posting this and gave myself a big eye-roll. It may be an easy first issue.

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024

Yeah, go for it! Organizationally, I'm not totally sure where this should go since none of the Lua scripting so far relates to visuals. For easy testing you might want to place it in init.lua and then once you've got it working create a separate module that gets loaded in init.lua if a config option is set. Whatever makes sense to you.

from mkdnflow.nvim.

trev-dev avatar trev-dev commented on May 16, 2024

Hey, apologies. I've taken a stab at this a couple of times in the last couple of weeks. Turns out grasping all the quirks of vim's syntax system is escaping me. I'm trying to change things with Lua, nothing seems to be happening. I have written syntax with vimscript in the past and it had worked. I have dumbed down the implementation to match a simple string, it won't conceal.

I am losing confidence in my configuration/set-up or perhaps just my ability to help with this in some timely manner.

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024

No worries! I haven't done anything with conceal before but would like to try to figure it out. I'll share details here if I figure it out just in case it's of interest.

from mkdnflow.nvim.

trev-dev avatar trev-dev commented on May 16, 2024

It should be almost dead simple*

* provided that your syntax configuration is sound and you know your pearl regex.

Its supposed to be a simple match group:

syntax match MkdnflowHideable conceal ”foo"
set conceallevel 1 ; something larger than 0
syntax conceal on

Obviously syntax should be on. I think my problem is I am not using the ./syntax/markdown.vim path but this is Lua...so...what now?

from mkdnflow.nvim.

trev-dev avatar trev-dev commented on May 16, 2024

I was beating my head against making it work from the lua/ folder as a configuration import in the entrypoint (init.conceal).

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024

That would be nice, but yeah, I couldn't get it to work from anywhere in the lua folder. Just in case it's useful, I tried the following checkbox conceals in markdown.vim inside a new syntax directory (lifted from a couple of comments in https://www.reddit.com/r/vim/comments/h8pgor/til_conceal_in_vim/):

call matchadd('Conceal', '\[\ \]', 0, 11, {'conceal': ''})
call matchadd('Conceal', '\[x\]', 0, 12, {'conceal': ''})
highlight Conceal ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE
setlocal conceallevel=1

from mkdnflow.nvim.

trev-dev avatar trev-dev commented on May 16, 2024

You nailed it.

lua/mkdnflow/conceal.lua:

local cmd = vim.cmd

local conceal = function(pattern)
  cmd("call matchadd('Conceal', "..pattern..", 0, 11, {'conceal': ''})")
end

vim.bo.syntax = 'on'
vim.wo.conceallevel = 3
cmd('syntax conceal on')
conceal('"Pandas"')

local M = {}
return M

matchadd seems to be the key here. The match "Pandas" now magically disappears until my cursor is on that line.

Would you like me to continue from here or are you on a roll?

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024

If you're interested, you should continue! I probably wouldn't be able to work on this for a few more days. If you get it to the point where you're relatively happy with the conceals, you can submit a PR and I can go ahead and do the configuration to enable/disable the conceals in the user config.

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024

@trev-dev how goes it on the conceal front?

from mkdnflow.nvim.

trev-dev avatar trev-dev commented on May 16, 2024

Apologies, and thanks for the reminder. I've moved on from using NeoVim for the time being and I lost track of this.

I took another stab at it regardless and pattern matching something like [<stuff has to be here but don't include it>](possible/path/string) is driving me a bit nuts. I'm going to have to pass the torch back.

from mkdnflow.nvim.

jakewvincent avatar jakewvincent commented on May 16, 2024

No worries, thanks for the update!

from mkdnflow.nvim.

trev-dev avatar trev-dev commented on May 16, 2024

Would you look at all of that regex soup :) - Well done.

from mkdnflow.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.