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

feat: add nvim support for isInEditor #507

Merged
merged 1 commit into from
Jun 18, 2024
Merged

Conversation

ryoppippi
Copy link
Contributor

@ryoppippi ryoppippi commented Jun 17, 2024

Description

add nvim support for isInEditor

Linked Issues

Additional context

Copy link

netlify bot commented Jun 17, 2024

Deploy Preview for melodious-froyo-4871f8 ready!

Name Link
🔨 Latest commit 2ce1030
🔍 Latest deploy log https://app.netlify.com/sites/melodious-froyo-4871f8/deploys/6670a0cf4295690008690f1b
😎 Deploy Preview https://deploy-preview-507--melodious-froyo-4871f8.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@thenbe
Copy link
Contributor

thenbe commented Jun 18, 2024

There's really no harm in merging this either way, but wasn't process.env.VIM already detecting that you were in neovim? (i.e. :lua =vim.env.VIM)

Ref #365

@ryoppippi
Copy link
Contributor Author

ryoppippi commented Jun 18, 2024

Oh, :=vim.env.VIM works for me!
and :=vim.env.NVIM is nil.

But when I launch :terminal, and execute echo $VIM, no variable set,
However, executing echo $NVIM shows the Neovim's tmp dir.

So, idk we need this PR anymore, but if you know something, please tell me what is the difference
@thenbe

@ryoppippi ryoppippi closed this Jun 18, 2024
@ryoppippi
Copy link
Contributor Author

ryoppippi commented Jun 18, 2024

@thenbe
you can see :h $NVIM

                                                                     *$NVIM*
                $NVIM is set by |terminal| and |jobstart()|, and is thus
                a hint that the current environment is a subprocess of Nvim.
                Example: >vim
                  if $NVIM
                    echo nvim_get_chan_info(v:parent)
                  endif
<
 
                Note the contents of $NVIM may change in the future.

So, when running eslint with jobstart, $NVIM variable is set.
idk it is good for detecting InEditor

@ryoppippi ryoppippi reopened this Jun 18, 2024
@thenbe
Copy link
Contributor

thenbe commented Jun 18, 2024

The main purpose of isInEditor is to prevent some rules from running on save (see here) because they could get annoying. Instead isInEditor was introduced to constrain those rules to only run when eslint is invoked through the cli (either manually by user, or pre-commit hook, etc).

I'm not familiar with the jobstart workflow myself, but if you're using jobstart and feel like those "aggressive" rules should not run during that sort of workflow then we should proceed with this PR and detect process.env.NVIM.

@antfu antfu changed the title add nvim support for isInEditor feat: add nvim support for isInEditor Jun 18, 2024
@antfu antfu merged commit 8f992fe into antfu:main Jun 18, 2024
12 checks passed
@ryoppippi ryoppippi deleted the feature/nvim branch June 18, 2024 18:39
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.

3 participants