woosaaahh / sj.nvim

Search based navigation combined with quick jump features.
MIT License
127 stars 3 forks source link

feat: add 'user_prefix' option #27

Closed ziontee113 closed 1 year ago

ziontee113 commented 1 year ago

Hi @woosaaahh, long time no see.

This is a draft of a feature that would add a "user_prefix" option when users call sj.run(). If the user wants to search jump to some patterns over and over again, instead of manually typing the pattern, they can use this "user_prefix" option to automatically type that pattern whenever they press the keymap.

I'd love to hear your feedback on this. Thanks for the amazing plugin :+1:

woosaaahh commented 1 year ago

Hi @ziontee113 ! Indeed, long time no see.

If I understand correctly, the goal is to use what I would call "predefined patterns" ? Those patterns would come from a config file, an history, a result of another plugin... If that's what you want/need, I really like the idea !

I read the PR changes very quickly and to be honest, I'm not sure I like your current implementation. (+ the Session.vim in .gitignore) I don't want to go too fast on this and I'm really busy this week. I'll check next week or implement it.

If you can't wait, either use your fork or use sj.cache.state.last_used_pattern = "foobar" + sj.options.use_last_pattern = true like in this little snippet

local sj_cache = require("sj.cache")

vim.keymap.set({ "n", "o", "x" }, "<leader>mf", function()
  sj_cache.state.last_used_pattern = "function"
  sj.run({ use_last_pattern = true, })
end)

I won't close/merge this PR until more reading (next week).

ziontee113 commented 1 year ago

Thank you for showing me the sj.cache.state.last_used_pattern = "foobar" way. I'll try it out soon :+1: Take your time man. No need to rush. I just need something usable and they already here :smile: Thanks again for the great plugin :+1:

woosaaahh commented 1 year ago

Hi !

As I said earlier, I don't really like the implementation.

I close the PR but I'll add the feature for sure !

woosaaahh commented 1 year ago

Hi !

The feature was added with e2f706e0cd181f23b0f1917d10e43e63c90ddeaa. For now, you can try it with the branch 0.7. There is a config example in the commit message.

CC: @ziontee113

ziontee113 commented 1 year ago

That's awesome, thank you very much :+1: