Git Product home page Git Product logo

live-command.nvim's Introduction

My GitHub stats

live-command.nvim's People

Contributors

smjonas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

live-command.nvim's Issues

Strange behavior with macro "dd" when rows are identical

So this behavior is kinda hard to explain and i dont fully understand it myself. Basically when saving "dd" to a macro it behaves very weirdly when the text is the same. It starts from the second to last row and goes up. When i changed to only a few rows being the same it started from the last of the similar rows and counted upwards. Once it had finished it started going down as normal

A bonus bug i found is that if you have recorded "dd" to q and then override it (for example i wrote "testing" at the end of the line), the preview will show both the previous macro to delete and the new macro. Although when you click enter the result is as you expect, but the preview is wrong.

Lastly I am sorry that i didnt have screenkey. I couldnt get it to work on fedora wayland :/ You have to take my word that i recorded "dd"

Screencast.from.2023-02-26.17-45-56.webm

this is the minimal example i used (thank god for NVIM_APPNAME)

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

vim.g.mapleader = " " -- make sure to set `mapleader` before lazy so your mappings are correct

require("lazy").setup({
	{"smjonas/live-command.nvim",
  opts = {
    commands = {
      Norm = { cmd = "norm" },
      Reg = {
        cmd = "norm",
        -- This will transform ":5Reg a" into ":norm 5@a"
        args = function(opts)
          return (opts.count == -1 and "" or opts.count) .. "@" .. opts.args
        end,
        range = "",
      },
    },
}
}
})

expected table, got nil

my config is just calling the setup function and when start nvim i get this error

E5113: Error while calling lua chunk: ...packer\start\live-command.nvim/lua\live-command\init.lua:309: commands: expected table, got nil
stack traceback:
	[C]: in function 'error'
	vim/shared.lua:699: in function 'validate'
	...packer\start\live-command.nvim/lua\live-command\init.lua:309: in function 'validate_config'
	...packer\start\live-command.nvim/lua\live-command\init.lua:346: in function 'setup'
	...ers\marzouk\AppData\Local\nvim/lua\user\live-command.lua:13: in main chunk
	[C]: in function 'require'
	C:\Users\marzouk\AppData\Local\nvim\init.lua:31: in main chunk

Question/Brainstorming: Recommendation for managing macros

Do you have a recommendation for storing and loading macros with lua?

  1. If I store them inside the lua file, stylua gets invalid UTF8 errors.
  2. Macros tend to be tailored to a language or project, so storing them in another repo (not with the dotfiles) sounds like a good idea.
  3. I did not find anything in lua yet.
  4. Macro debugging is horribly hard. They fail silently and may fail with or without any action. Any kind of visually highlighting that "something was changed" and "it failed" would be helpful.
  5. It would be extremely helpful, if there could be a highlighting of lines, which a macro can be applied to. Think of single and multiline code inside switches,if-else prongs, where one wants to know that each switch case/if-else works before trying.
  6. Checking for "marker symbols inside the line/section" before applying the macro and saving this info alongside the macro would be awesome. This would allow fast inspection, if the macro "would do something". Logic could be applied on top of that.

Please let me know, what you think of those ideas and how to structure them into actionable items (for investigation).

Looking for testers

This plugin is almost ready to be released and I am currently looking for testers. What you can do to help out:

  • Test the :Norm and Reg commands and look out for any highlighting or performance issues.
  • Add your own commands that you want to preview and see if you notice any unexpected behavior.
  • Please share your commands if you think they make sense to be previewed, then I can include them in the readme!
  • Let me know if you were confused by anything in the readme or if you would like some things to be fleshed out / clarified.

Thank you, I really appreciate any help / feedback from you guys!

Nitpick, unimportant, no one cares problem in combination with numb

I encountered a small issue when using Reg in combination with numb. When i try to write 5Reg q it jumps to the fifth row and executes the query there. There is probably nothing to be done about this but id thought i should let you know anyway, feel free to close this

Screencast.from.2023-02-26.17-12-48.webm

Issue when normal command does not match

Really cool plugin! I started taking it for a spin and one issue I noticed is that the preview is not correct if some line does not contain a match for eg f.

For example lets say you have the buffer:

foo
bar

and you type :%Norm foix. Then before pressing <CR> the preview looks like:

fxoo
xbar

whereas after pressing <CR> you actually get:

fxoo
bar

confusing display with inline_highlighting

I used live-command to wrap vim-abolish:

  use {'smjonas/live-command.nvim', commit='ce4b104ce702c7bb9fdff863059af6d47107ca61', config=function()
    require("live-command").setup {
      defaults = {
        -- inline_highlighting = false,
      },
      commands = {
        Norm = { cmd = "norm" },
        S = { cmd = "Subvert"}, -- must be defined before we import vim-abolish
      },
    }
  end}

With an input file of:

result
Result
RESULT

And when previewing this command:
%S/result/outcome

This is the display:
image

Ideally the display would be like neovim's :%s preview meaning resultoutcome

Disabling inline highlighting helps with that issue, but then whole lines are highlighted and it's not clear anymore what was changed.
Making a word-by-word diff would help in this case, I guess.

How to preview :g commands

Can this plugin be used to preview :g? For example lets say I have the buffer:

foo
bar
barx
foo
xbar

and I want to delete any line containing bar which could be done with :g/bar/d<CR>. However if I add the entry G = { cmd = 'g' } to the config of this plugin. It only previews the command on the current line when I type :G/bar/d, even though :g acts on all lines.

live-command doesn't work with unranged :Subvert

tpope/vim-abolish provides a useful :Subvert command that does smart substitution.

I've configured it with live-command as so:

use {
  "smjonas/live-command.nvim",
  config = function()
    require("live-command").setup {
      commands = {
        LSubvert = { cmd = "Subvert" },
      },
    }
  end,
}

but I'm getting an error when I try :LSubvert/send_wire/SendWire/:

Error executing Lua callback: ...packer/start/live-command.nvim/lua/live-command/init.lua:281: Vim(substitute):E486: Pattern not found: \v\C%(send_wire|SEND_WIRE|SendWire)   
stack traceback:                                                                                                                                                              
        [C]: in function 'cmd'                                                                                                                                                
        ...packer/start/live-command.nvim/lua/live-command/init.lua:281: in function 'execute_command'                                                                        
        ...packer/start/live-command.nvim/lua/live-command/init.lua:295: in function <...packer/start/live-command.nvim/lua/live-command/init.lua:288>

The plugin works when I provide a range though, e.g., :%LSubvert/send_wire/SendWire/.

I can provide a Docker container for reproducing this issue if needed.

Tracking issue: highlighting improvements / tweaks

There are probably a million ways the highlighting algorithm can be improved.
Here are some examples:

In progress

  • input: oneword, output: hey, expected highlights: a single replacement highlight created by joining multiple highlights, any deletions should be removed. This would involve detecting word boundaries. Status: in progress, see #8.

Planned

  • input: foo, output: o, expected highlights: a single replacement highlight (the suffix o should not have been truncated)

Completed

  • input timestamp, _ := strconv.Atoi(line[0]), output: timestamp = strconv.Atoi(line[0]),, check highlights! Fixed in f713c59.

preview is wrong, see images

Hi,

first of all: this is a nice plugin! So... issue:

Screenshot_20221006_163728

Screenshot_20221006_163747

As you can see the preview does not match the result.

Using current neovim stable.

Regards

Deleting text leads to strange results

For example, I selected two lines and typed :Norm de, and then deleted the previous two characters. This made it so another word got deleted on each line. I then pressed <Esc> to cancel, which didn't revert one of the deletions.

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.