Skip to content

Go: Add gotype support#1099

Merged
w0rp merged 12 commits into
dense-analysis:masterfrom
JelteF:gotype
Jan 7, 2018
Merged

Go: Add gotype support#1099
w0rp merged 12 commits into
dense-analysis:masterfrom
JelteF:gotype

Conversation

@JelteF

@JelteF JelteF commented Nov 8, 2017

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread ale_linters/go/gotype.vim Outdated
\ 'name': 'gotype',
\ 'output_stream': 'stderr',
\ 'executable': 'gotype',
\ 'command': 'gotype -e %t $(find $(dirname %s) -maxdepth 1 -name "*.go" | grep -v "^"%s"$")',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This command uses Bash syntax. This isn't portable.

Does this command accept files via stdin? Or do you need to pass all of the .go files to the command? ALE adds < TEMPORARY_FILENAME by default to the end of the command with the contents of the buffer.

@JelteF

JelteF commented Nov 8, 2017 via email

Copy link
Copy Markdown
Contributor Author

@w0rp

w0rp commented Nov 8, 2017

Copy link
Copy Markdown
Member

You'll have to see if there's some portable way of making the linter check all of the files you need to check. What happens if you only pass just the one file you're editing instead?

@w0rp

w0rp commented Nov 8, 2017

Copy link
Copy Markdown
Member

Add 'lint_file': 1 to the Dictionary if you have to check files on disk.

@JelteF

JelteF commented Nov 8, 2017 via email

Copy link
Copy Markdown
Contributor Author

@JelteF

JelteF commented Nov 8, 2017 via email

Copy link
Copy Markdown
Contributor Author

@w0rp

w0rp commented Nov 8, 2017

Copy link
Copy Markdown
Member

You can only check for errors while you type if the tool supports it. I don't know if gotype supports checking files via stdin with support for imports.

@JelteF

JelteF commented Nov 8, 2017 via email

Copy link
Copy Markdown
Contributor Author

@JelteF

JelteF commented Nov 8, 2017 via email

Copy link
Copy Markdown
Contributor Author

@w0rp

w0rp commented Nov 8, 2017

Copy link
Copy Markdown
Member

Okay then. You'd just need to come up with something which works equally well on Linux, Mac, and Windows for ti to be considered for inclusion in this repository.

@JelteF

JelteF commented Nov 9, 2017 via email

Copy link
Copy Markdown
Contributor Author

@w0rp

w0rp commented Nov 9, 2017

Copy link
Copy Markdown
Member

You can't rely on just about any shell features, including *. You can write a command_callback to implement all kinds of behavior. Have a look at some of the existing linters.

@JelteF

JelteF commented Nov 9, 2017 via email

Copy link
Copy Markdown
Contributor Author

@JelteF

JelteF commented Nov 9, 2017

Copy link
Copy Markdown
Contributor Author

I just pushed a version where I converted my shell globbing and filtering to vim globbing and filtering by using command_callback. Is this good enough?

@w0rp w0rp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It it possible to use a directory name instead of a glob? Globbing can execute pretty slowly. The time frame for getting a command to run is around 16ms.

@JelteF

JelteF commented Nov 9, 2017 via email

Copy link
Copy Markdown
Contributor Author

@w0rp

w0rp commented Nov 9, 2017

Copy link
Copy Markdown
Member

I recommend passing the actual filename and only checking for errors on save or enter then. That's how most of the other Go tools work. Nearly all Go tools don't support checking for errors via stdin.

@JelteF

JelteF commented Nov 10, 2017

Copy link
Copy Markdown
Contributor Author

The only glob I'm doing is in a single directory (not recursive), so I cannot really imagine it to be very slow. When I use it, it doesn't feel slow at least. The argument, that that's how the other go tools work I don't really get. This improvement could maybe be used for them as well.

@w0rp w0rp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's go with it and see what others make of it. Can you add a Vader test for the new function?

@JelteF

JelteF commented Nov 10, 2017

Copy link
Copy Markdown
Contributor Author

I can, but I won't be able to do it before I'm travelling anymore. So I will probably do it somewhere in december (just letting you know).

@w0rp

w0rp commented Nov 11, 2017

Copy link
Copy Markdown
Member

Okay, sounds good.

@JelteF

JelteF commented Dec 28, 2017

Copy link
Copy Markdown
Contributor Author

Ok it took a while, but I finally wrote some tests. Any clue what the cause of the error on AppVeyor is?

    (1/2) [EXECUTE] (X) Vim(let):E121: Undefined variable: C
      > function ale_linters#go#gotype#GetCommand, line 7

I don't define a variable C anywhere and Travis is fine so I'm a bit confused.

@w0rp

w0rp commented Jan 2, 2018

Copy link
Copy Markdown
Member

I'm not sure. I'll have to run the tests on Windows myself and see if I can figure out what is wrong.

@JelteF

JelteF commented Jan 2, 2018

Copy link
Copy Markdown
Contributor Author

Figured out the issue, I wasn't escaping a string correctly that was eval-ed as vimscript. Tests are passing now, so I think it can be merged now.

@w0rp

w0rp commented Jan 7, 2018

Copy link
Copy Markdown
Member

Okay, let's go with it.

@w0rp w0rp merged commit b6d1c41 into dense-analysis:master Jan 7, 2018
@w0rp

w0rp commented Jan 7, 2018

Copy link
Copy Markdown
Member

Cheers! 🍻

@w0rp

w0rp commented Mar 18, 2018

Copy link
Copy Markdown
Member

Due to this issue, I had to make gotype only check files on disk: #1392

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