-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add strings
module
#96
Conversation
could probably add this to align multibyte string as well. The lua |
Thanks for porting this :) Do you mind also adding border title truncate?
Max width is: |
Do you also wanna add this local dedent = function(str, leave_indent)
-- find minimum common indent across lines
local indent = nil
for line in str:gmatch('[^\n]+') do
local line_indent = line:match('^%s+') or ''
if indent == nil or #line_indent < #indent then
indent = line_indent
end
end
if indent == nil or #indent == 0 then
-- no minimum common indent
return str
end
local left_indent = (' '):rep(leave_indent or 0)
-- create a pattern for the indent
indent = indent:gsub('%s', '[ \t]')
-- strip it from the first line
str = str:gsub('^'..indent, left_indent)
-- strip it from the remaining lines
str = str:gsub('[\n]'..indent, '\n' .. left_indent)
return str
end |
@Conni2461 I added |
f92077f
to
2375e77
Compare
This needs nvim-lua/plenary.nvim#96 to be merged.
lua/plenary/strings.lua
Outdated
for line in str:gmatch('[^\n]*\n?') do | ||
-- It matches '' for the last line. | ||
if line == '' then | ||
goto CONTINUE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not use goto breaks lua 5.1 (and some people build neovim with it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed on a90e9b0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied again 8931abd
The original was just some hacky thing tj wrote so we can write tests like this: Its not really used in production but thanks anyways :) |
One other thing as well is that if there are any string functions that exist within neovim that would be useful but just aren't exposed, we can expose them over the |
@Conni2461 @tjdevries static int nlua_str_charpart(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
{
f_strcharpart(...); // What should be here for arguments?
return 1;
} |
Hey @delphinus , are you asking what code you would need to add to neovim core to be able to do this? If so, I can guide you through the PR that you'd probably want to be able to do that. |
@delphinus Whats the progress here? Some people are waiting for a telescope PR nvim-telescope/telescope.nvim#528 (comment) that is already done but requires the truncating border titles. I would be fine with merging a not done version here. (for example everything besides |
46abbca
to
dd0d8ab
Compare
Sorry for too large delay! I have been too busy to write code here, so I (or some person) will improve in the future when I have time ;( Can you merge this current code? |
dd0d8ab
to
d06bd74
Compare
d06bd74
to
9c7f829
Compare
9c7f829
to
a90e9b0
Compare
a90e9b0
to
bbf658a
Compare
Somehow the Can you also rebase nvim-telescope/telescope.nvim#690 so i can test it in combination? After that i think we can merge. Thanks :) |
bbf658a
to
8931abd
Compare
This needs nvim-lua/plenary.nvim#96 to be merged.
Fixed again. and nvim-telescope/telescope.nvim#690 is also ready. |
@tjdevries @Conni2461 any chance you can take a look at this PR? As far as I can tell it is blocking nvim-telescope/telescope.nvim#528 which I quite fancy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I ask tj if i can merge it :)
Sorry there was a "typo" i missed. Should be fixed |
Thank that fixed the problem |
This needs nvim-lua/plenary.nvim#96 to be merged.
ref #95
ref nvim-telescope/telescope.nvim#464
TODO