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

Fix a format for echoed string #48

Closed
KabbAmine opened this issue Oct 6, 2016 · 8 comments
Closed

Fix a format for echoed string #48

KabbAmine opened this issue Oct 6, 2016 · 8 comments

Comments

@KabbAmine
Copy link
Contributor

Now each linter use its own format for the echoed message, so it will be great to decide and specify only one format to use.

IMHO something like that will be good:

When we know the severity

:[linter-name] Severity - Text

And when we don't know:

:[linter-name] Text

Note that the 1st letter of severity/text is in capital.
I'm thinking that linter-name can be helpful for the file types using multiple ones.

@w0rp If you agree, I can make a PR.

@KabbAmine KabbAmine changed the title Fix a format for echo string Fix a format for echoed string Oct 6, 2016
@w0rp
Copy link
Member

w0rp commented Oct 6, 2016

Yeah, sounds good. I think there should be some options for enabling/disabling the linter name and the severity. I suppose there would only be two severity values at the moment, "Error" and "Warning." I'd set the linter names and the Severity to be off by default, and explain the new flags in the README and the new help file.

@w0rp
Copy link
Member

w0rp commented Oct 6, 2016

These kinds of messages will be especially helpful once quickfix support is in.

@KabbAmine
Copy link
Contributor Author

Most of the time, only 'Error' and 'Warning' are reported by linters (Sometimes 'Style') so yes, those two are enough.

@KabbAmine
Copy link
Contributor Author

I've already started to work on this, and the severity + type are already done (Disabled by default and configurable).

But for the linter, I still don't know where can I get the name of the current used one.
Temporary, I've added a key name to be returned with the output of linter handlers, then added it to g:ale_buffer_loclist_map and that works. But I think that is not a good way to proceed.

Any idea?

@w0rp
Copy link
Member

w0rp commented Oct 8, 2016

You'll have to associate each warning/error with each linter, as more than one linter could be run for the same buffer. I'd try adding a key to each of the loclists returned by the Handle functions which maps to the linter name the warnings and errors are for, and see if that breaks setting the loclist at all. If it doesn't, then you should be able to read that key in the echo functions to get the linter names.

I'm thinking of something like this in s:HandleExit.

for item in linter_loclist
    item.linter_name = linter.name
endfor

@KabbAmine
Copy link
Contributor Author

I'd try adding a key to each of the loclists

Try that. Make a branch where we'll work.

@w0rp
Copy link
Member

w0rp commented Oct 9, 2016

Check out the echo-string-format branch. I added the linter_name key as described, and everything seems to work fine with it being there. Now you should be able to run through the items from g:ale_buffer_loclist_map and get the type and linter name from there.

@KabbAmine
Copy link
Contributor Author

Great thanks. I'll come with something tomorrow.

KabbAmine added a commit to KabbAmine/ale that referenced this issue Oct 10, 2016
Via `g:ale_echo_msg_format` where:
- `%s` is the error message itself
- `%linter%` is the linter name
- `%severity` is the severity type

e.g
let g:ale_echo_msg_fomat = '[%linter%] [%severity%] %s'
KabbAmine added a commit to KabbAmine/ale that referenced this issue Oct 10, 2016
Via `g:ale_echo_msg_format` where:
- `%s` is the error message itself
- `%linter%` is the linter name
- `%severity` is the severity type

e.g
let g:ale_echo_msg_fomat = '[%linter%] [%severity%] %s'
w0rp pushed a commit that referenced this issue Oct 10, 2016
* Implement an option to configure the echoed message, #48

Via `g:ale_echo_msg_format` where:
- `%s` is the error message itself
- `%linter%` is the linter name
- `%severity` is the severity type

e.g
let g:ale_echo_msg_fomat = '[%linter%] [%severity%] %s'

* Add new options for defining the string used for errors in echoed
message

`g:ale_echo_msg_error_str` and `g:ale_echo_msg_warning_str`

* Change text output of some linters

Now that the echoed message can be customized, no need to add the type
to the text variable.

* Update README & documentation file

* Fix some typos
* Sort the table of options alphabetically (except echo_msg_x_str options)

* Added echo warning str option to the doc
@w0rp w0rp closed this as completed Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants