Giter Club home page Giter Club logo

Comments (4)

Andriamanitra avatar Andriamanitra commented on May 26, 2024 1

@Andriamanitra How would I get the information that insert mode is active in a lua plugin?

As far as I know the overwrite mode always starts as false so the simplest way is to catch the ToggleOverwriteMode event:

local micro = import("micro")

overwriteMode = false

function onToggleOverwriteMode(bufpane)
    overwriteMode = not overwriteMode

    if overwriteMode then
        micro.InfoBar():Message("Insert mode ON")
    else
        micro.InfoBar():Message("Insert mode OFF")
    end
end

You may want to use a table instead of a boolean to keep track of insert mode state per buffer but hopefully this is enough to get you started.

from micro.

Andriamanitra avatar Andriamanitra commented on May 26, 2024

There are a few possible complementary ways to achieve it:

  • When pressing the Insert key, it will show "Insert" or "Overwrite" in the status line
  • It can be supported through a function that's available statusformatl / statusformatl , e.g. $(overwritemode)

You could write a plugin to accomplish either of these two.

  • The cursor can change (may not work on all terminals)

This one probably need changes in the editor itself but I'm not sure if it's a good idea when you consider the terminal support issue.

from micro.

taconi avatar taconi commented on May 26, 2024

@Andriamanitra How would I get the information that insert mode is active in a lua plugin?

from micro.

dmaluka avatar dmaluka commented on May 26, 2024

You may want to use a table instead of a boolean to keep track of insert mode state per buffer

To be precise, it should be per bufpane, not per buffer. Overwrite mode is per pane, and the same buffer may be opened in multiple panes.

from micro.

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.