Skip to content
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

Bug: nix filetype #1

Open
kkharji opened this issue Mar 24, 2021 · 12 comments
Open

Bug: nix filetype #1

kkharji opened this issue Mar 24, 2021 · 12 comments

Comments

@kkharji
Copy link

kkharji commented Mar 24, 2021

Hey @AckslD, awesome work, I like the concept of it a lot.

I've gave it a try and at first, it appended , to the end of the list where it shouldn't have because of how nix syntax.
So I've create a setting function that let's me decide when to skip adding comma to the end of the list like so:

settings = {
...
    add_last_colon_if_missing = function ()
        return true
    end,

}
local add_last_colon_if_missing = function(end_pos)
    if not settings.add_last_colon_if_missing() then return end
    ....
end

I'm sure you have way better idea for this issue.

But the real issue I have is how revj transforms this

  buildInputs = [ python3 python37Packages.numpy postgresql ];

to this

  buildInputs = [
      
      python3 python37Packages.numpy postgresql ];

Where it should've transformed it to this:

  buildInputs = [
      python3 
      python37Packages.numpy 
      postgresql 
  ];

Thanks

@AckslD
Copy link
Owner

AckslD commented Mar 24, 2021

Hi @tami5! Thanks for the feedback!

Currently only , and ; as separators are supported since this is what vim-textobj-parameters uses, which provides the notion of what is a parameter. However, I'm right now looking into how to use treesitter instead, which would then make it a lot easier to get the notion of what is an argument/parameter for different languages. Although, nix does not seem to have full support yet, see here, but hopefully someone will add it :)

@kkharji
Copy link
Author

kkharji commented Mar 24, 2021

Oh I see, Yah I think tree-sitter would be better. Thanks

Not sure if I need to open another issue for this, but when I tried it out on lua, it indented the list items 4 space instead of 2 space.

@AckslD
Copy link
Owner

AckslD commented Mar 24, 2021

Ah good point! I use 4 spaces for everything so didn't notice this. I'll open a separate issue for that. See #2

@kkharji
Copy link
Author

kkharji commented Mar 24, 2021

Thanks @AckslD

@AckslD
Copy link
Owner

AckslD commented Mar 24, 2021

@tami5 Could you update the plugin and see if the indentation works for you now?

@kkharji
Copy link
Author

kkharji commented Mar 26, 2021

Yep the indentation is fixed, but I noticed that it insert a comma even though there is a comma at list item in the list.

  requires = { 'nvim-lua/lsp_extensions.nvim', 'onsails/lspkind-nvim', 'glepnir/lspsaga.nvim', }

to

  requires = {
    'nvim-lua/lsp_extensions.nvim',
    'onsails/lspkind-nvim',
    'glepnir/lspsaga.nvim',
    ,
  }

@AckslD
Copy link
Owner

AckslD commented Mar 26, 2021

@tami5 Thanks for pointing this out! This seems to be an issue with vim-textobj-parameter since it thinks that the last space is a parameter. For now I added an explicit check for this case, see #7 and #8.

Btw, another issue I noticed is that if there is no whitespace at all after that last comma or more generally when either the motion or visual selection starts/ends on a comma. This is because when the cursor is on a comma vim-textobj-parameter does not consider this a parameter. I guess since it's not clear if the left or right is meant. We could have a check if we're on a comma and either move left or right. However, it's not clear to me what a good default is, i.e either include surrounding arguments on a comma or only the internal ones. Any thoughts?

@kkharji
Copy link
Author

kkharji commented Mar 26, 2021

Amazing work @AckslD . hmmm I'm not quite sure If I understand you correctly? can you show a textual demo

@AckslD
Copy link
Owner

AckslD commented Mar 27, 2021

@tami5 Yeah maybe it wasn't very clear :) So let's say you have for example:

(1,2,3,4,5,6)

and you're cursor is the , after the 2. If you now do <Leader>Jt5 the motion selected is the following

    |---|
(1,2,3,4,5,6)

now the question is which parameters should be made so that they are on separate lines, i.e. should it be

  • {2,3,4,5} (greedy)
  • {3,4,5} (end-greedy)
  • {2,3,4} (start-greedy)
  • {3,4} (strict)

I've now opted for strict but without any real reason so if anyone has a opinion on this I'm happy to change it.
With the current implementation the output of the above becomes:

(1,2,
    3,
    4,
    5,6)

@kkharji
Copy link
Author

kkharji commented Mar 27, 2021

Yah I feel strict make sense. Although I'd find my self rarely using the above use case as I like to have the same reverse behavior of J at the same line. By thar I mean <leader>j i. normal mode transfers lists into multiple lines

@AckslD
Copy link
Owner

AckslD commented Apr 11, 2022

Hi @tami5, in case you're still interested in this, I've started a complete re-write of this plugin which uses treesitter and in general I think a much better implementation. Feel free to check it out :)

https://github.com/AckslD/nvim-trevJ.lua

@kkharji
Copy link
Author

kkharji commented Apr 11, 2022

Great news @AckslD 😍 . surething

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

No branches or pull requests

2 participants