-
Notifications
You must be signed in to change notification settings - Fork 15
add user command Trim and config.trim_on_write #16
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
Conversation
- add function based on previous update: . TrimNow: user command to call directly . trim_on_write: config option to control the initial state - compatability change: . config.disable rename to config.blacklist
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.
Thanks for your PR.
In this PR, let's avoid breaking compatibility.
Please make no changes from diable
to blacklist
.
README.md
Outdated
@@ -62,3 +66,7 @@ require('trim').setup({ | |||
### `:TrimToggle` | |||
|
|||
Toggle trim on save. | |||
|
|||
### `:TrimNow` |
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.
Since it is obvious that the command will be executed immediately, I want to name it 'Trim'.
### `:TrimNow` | |
### `:Trim` |
plugin/trim.lua
Outdated
@@ -13,3 +13,9 @@ vim.api.nvim_create_user_command('TrimToggle', function(args) | |||
end, { | |||
range = false, | |||
}) | |||
|
|||
vim.api.nvim_create_user_command('TrimNow', function(args) |
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.
vim.api.nvim_create_user_command('TrimNow', function(args) | |
vim.api.nvim_create_user_command('Trim', function(args) |
lua/trim/init.lua
Outdated
@@ -73,4 +74,10 @@ function M.disable() | |||
vim.notify('TrimNvim disabled', vim.log.levels.INFO, { title = 'trim.nvim' }) | |||
end | |||
|
|||
function M.trim() | |||
if not has_value(M.config.blacklist, vim.bo.filetype) then |
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.
Since the user is executing the command themselves, I don't think it is necessary to change the behavior depending on the file type.
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.
Thanks for your PR.
In this PR, let's avoid breaking compatibility. Please make no changes from
diable
toblacklist
.
As disable
is more like a boolean option to disable the plugin totally, I think it's better to move to blacklist
.
For compatibility issue, the latest commit add another check to handle the case, it will try to use disable
if blacklist
is not present, the logic is simple and should be enough for seamless switch 🙂
- manually Trim should work on all files
- use `disable` if present when `blacklist` not set
README.md
Outdated
@@ -36,8 +36,9 @@ use({ | |||
```lua | |||
-- default config | |||
local default_config = { | |||
disable = {}, | |||
blacklist = {}, |
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.
I would like to use blocklist
instead of blacklist
.
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.
In addition, since the blocked targets are based on file type, I would like to name it ft_blocklist
.
lua/trim/init.lua
Outdated
@@ -24,6 +25,12 @@ end | |||
|
|||
function M.setup(opts) | |||
opts = opts or {} | |||
|
|||
-- compatability: disable -> blacklist | |||
if (opts.disable and not opts.blacklist) then |
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.
Thank you for considering compatibility 👍
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.
LGTM 👍
Thanks for your contribution.
add function based on previous update:
. TrimNow: user command to call directly
. trim_on_write: config option to control the initial state
compatability change:
. config.disable rename to config.blacklist