Giter Club home page Giter Club logo

Comments (4)

echasnovski avatar echasnovski commented on May 21, 2024 1

In the end, I decided to leave writing these rules to user. There are examples for common situations in mini.nvim-disabling-recipes help tag.
Thanks for suggestion nevertheless!

from mini.nvim.

echasnovski avatar echasnovski commented on May 21, 2024

Thanks for your feedback!

I considered this early on, but decided to stick with current mechanism using global and buffer "disabling" variables. It enables quite flexible behavior while being very fast. Having settings specifically for filetypes will be either a duplication (which doesn't quite align with plugin idea of balancing between features and support) or separate mechanism which might slow things down (which is crucial for something that is executed on every CursorMoved). This also might be a precedent to include another conditions in setup(), which I don't really want. Currently I have strong opinion about this subject, but for the time being I'll keep this open as a reminder to try and reconsider.

What might be a more appropriate thing to do is to provide in help more explicit code snippets for most common scenarios. I just tried really quickly to implement your case (I admit, should be a quite common one) with autocmd and it is not trivial. This plugin is designed more towards "disable this module under these handful of conditions" and not "enable ... conditions", which might be a problem for not experienced users. I'll think about it.

from mini.nvim.

bart-jaskulski avatar bart-jaskulski commented on May 21, 2024

I see, in such case it may be more reasonable to rely on disabling for selected filetypes. Actually, the outcome is similar to desired.

  vim.cmd [[ autocmd BufReadPost *.md let b:minicursorword_disable=v:true ]]

I've been thinking for a moment on the setup for possible snippet and indeed this is more complex. The best, low effort idea I've came up with would be toggling global state of module, what itself just seems odd.

use {
  'echasnovski/mini.nvim',
  config = function()
    vim.g.minicursorword_disable = true
    require'mini.cursorword'.setup()
  end
}

  vim.cmd [[ autocmd BufReadPost *.md let g:minicursorword_disable=v:true ]]
  vim.cmd [[ autocmd BufReadPost *.php,*.js,*.html,*.css let g:minicursorword_disable=v:false ]]

from mini.nvim.

echasnovski avatar echasnovski commented on May 21, 2024

Yep, it this was an intended use case. You can also use it with FileType autocommand (autocmd FileType markdown ...) or with filetype plugins.

The most straightforward way to "enable only for certain file types" is to explicitly say "disable only if filetype is not a desired one". Using some Vimscript, this becomes something like:

vim.cmd([[au FileType * if index(['lua', 'python'], &ft) < 0 | let b:minicursorword_disable=v:true | endif]])

Note: of course, this can be improved (for example, it won't work if 'filetype' has changed after buffer is opened; which would require an else clause here), but it might become overcomplicated for small benefit.

from mini.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.