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

How to get hints on compiler errors ? And jump into editor on error file and line ? #4491

Closed
akharrou opened this issue Jan 10, 2022 · 5 comments

Comments

@akharrou
Copy link

akharrou commented Jan 10, 2022

Consider this:

❯ gcc -Wall main.c
main.c:6:3: error: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Werror,-Wimplicit-function-declaration]
  printf("Hello world\n");
  ^
main.c:6:3: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
main.c:4:7: warning: unused variable 'bla' [-Wunused-variable]
  int bla;
      ^
1 warning and 1 error generated.

How can you get hints on just main.c:6 and open vim directly on that line ?


Bonus: can you additionally include columns in this ? i.e hint selection would include them and vim opens cusor directly in that file, on that line, on that column.

@akharrou akharrou changed the title How to get hints on compiler errors ? How to get hints on compiler errors ? And jump into editor on error file and line ? Jan 10, 2022
@akharrou
Copy link
Author

akharrou commented Jan 10, 2022

https://sw.kovidgoyal.net/kitty/kittens/hints/#cmdoption-kitty-kitten-hints-linenum-action

@kovidgoyal I tried this:

# kitty.conf

map super+y kitten hints --type=linenum --linenum-action=tab nvim +{line} {path}

on the exact compiler errors above ...but I keep getting "No matches found, press Enter to quit."

@akharrou
Copy link
Author

akharrou commented Jan 10, 2022

I also tried this:

# kitty.conf
map super+y _hints --linenum-action=window --type=regex --regex="\b(?P<filepath>.+):(?P<line>\d+)(:(?P<column>\d+))?" --program="nvim +{line} {filepath}"

Which gives me matches on more than just what I need, by matching the command prompt paths, and doesn't seem to do anything once I select a hint... something wrong with my usage of --program ?

Screen Shot 2022-01-10 at 11 03 39 AM

So I also tried removing --program … like in other examples...

# kitty.conf
map super+y _hints --linenum-action=window --type=regex --regex="\b(?P<filepath>.+):(?P<line>\d+)(:(?P<column>\d+))?" nvim +{line} {filepath}

...but that doesn't work either and I get: "Extra command line arguments present: vim + (line} {filepath} Press Enter to quit"

@page-down
Copy link
Contributor

main.c cannot be matched by the default rules (ext 2~7). This issue has also been on my list for a while.

def linenum_marks(...)
    # ...
    regex = r'(?P<path>(?:\S*/\S+?)|(?:\S+[.][a-zA-Z0-9]{2,7})):(?P<line>\d+)'

@kovidgoyal
Is there a negative impact if we add single-letter c, h, m files?

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jan 10, 2022 via email

This issue was closed.
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

3 participants