gaalcaras / ncm-R

R autocompletion for Neovim and vim 8 :memo: :bar_chart: :zap:
GNU General Public License v3.0
115 stars 10 forks source link

(WIP) Changes to improve data.table completion #20

Open matsburg opened 5 years ago

matsburg commented 5 years ago

This is where I've got to so far with the data.table completion behaviour as discussed in #18. There are two significant changes:

I've also added some test cases to demonstrate the behaviour I'm trying to get (which should currently all pass).

matsburg commented 5 years ago

I've worked on this a bit more now, the behaviour is only triggered for data.table objects and so there's no need for the ncm_r_dt option, which is removed. I've also added support for completion when using data.tables with the magrittr pipe %>%, like this:

DT %>%
  .[i, j, by]

Note that you can also do this with ordinary data.frames, i.e.

DF %>%
  .[, "column_name"]

and completion works as expected in this case too. Coincidentally, this pipe completion behaviour isn't supported by RStudio :)

When adding this pipe behaviour I noticed that the regex used for detecting if completion is happening inside the brackets of a df doesn't allow for the name of the df to contain dots (since \w includes '_' but not '.') Hence this PR also fixes this bug. But I'd be happy to split out this fix into a separate PR if it would be more appropriate.