atom / language-go

Go language package for Atom
Other
106 stars 58 forks source link

Import scope is gone #166

Open veger opened 5 years ago

veger commented 5 years ago

Description

The golang language used to have a entity.name.import.go scope, which could be used to see if the grammar was inside an import block:

import (
    "context"
    "errors"
    "fmt"
)

or

import "context"

But I cannot find this in the tree-sitter grammar rules (which seems to be used now?)

Is this expected, or forgotten to include?

My linter-spell-go package was using this to disable spell checking on import strings, that is how I noticed this issue.

Steps to Reproduce

  1. Open a golang file with some imports
  2. Move cursor to an import block
  3. Run Editor: Log Cursor Scope command

Expected behavior:

Scopes at Cursor
  source.go
  string.quoted.double
  entity.name.import.go

(or something like this, I cannot get the original anymore since it is gone)

Actual behavior:

Scopes at Cursor
  source.go
  string.quoted.double

Versions

$ atom --version
Atom    : 1.34.0
Electron: 3.1.1
Chrome  : 66.0.3359.181
Node    : 10.2.0

$ apm --version
apm  2.1.3
npm  6.7.0
node 11.9.0 x64
atom 1.34.0
python 2.7.15
git 2.20.1
Aerijo commented 5 years ago

Likely a regression, not intentional. The Tree-sitter nodes are roughly

source.go
source_file
import_declaration
import_spec
interpreted_string_literal

so it shouldn't be too difficult to reintroduce the scope.

There are a couple of ways to disable Tree-sitter, both globally through Settings -> Core, or directly in the config file on a per language basis. But that shouldn't be needed.

rsese commented 5 years ago

👍 reproduced with 1.36.0-nightly10 on macOS 10.12.6.