Skip to content

Conversation

rtgiskard
Copy link
Contributor

  • 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

- 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
Copy link
Owner

@cappyzawa cappyzawa left a 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`
Copy link
Owner

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'.

Suggested change
### `: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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vim.api.nvim_create_user_command('TrimNow', function(args)
vim.api.nvim_create_user_command('Trim', function(args)

@@ -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
Copy link
Owner

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.

Copy link
Contributor Author

@rtgiskard rtgiskard Mar 2, 2023

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.

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 🙂

@rtgiskard rtgiskard requested a review from cappyzawa March 2, 2023 03:45
README.md Outdated
@@ -36,8 +36,9 @@ use({
```lua
-- default config
local default_config = {
disable = {},
blacklist = {},
Copy link
Owner

@cappyzawa cappyzawa Mar 2, 2023

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.

Copy link
Owner

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.

@@ -24,6 +25,12 @@ end

function M.setup(opts)
opts = opts or {}

-- compatability: disable -> blacklist
if (opts.disable and not opts.blacklist) then
Copy link
Owner

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 👍

@rtgiskard rtgiskard requested a review from cappyzawa March 3, 2023 05:42
Copy link
Owner

@cappyzawa cappyzawa left a 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.

@cappyzawa cappyzawa merged commit 9202bc3 into cappyzawa:master Mar 3, 2023
@cappyzawa cappyzawa changed the title add user command TrimNow and config.trim_on_write add user command Trim and config.trim_on_write Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants