Skip to content

Nvim setup fixes (POSIX Compatbility, Clang includes and Treesitter Querys)#7455

Open
pyqt555 wants to merge 1 commit into
carbon-language:trunkfrom
pyqt555:fix/neovim-setup
Open

Nvim setup fixes (POSIX Compatbility, Clang includes and Treesitter Querys)#7455
pyqt555 wants to merge 1 commit into
carbon-language:trunkfrom
pyqt555:fix/neovim-setup

Conversation

@pyqt555

@pyqt555 pyqt555 commented Jul 4, 2026

Copy link
Copy Markdown

###Description

This pr addresses several issues in the nvim setup tooling, namely:

  1. lsp invocation: this is more idiomatic (and in general should work on more systems)
  2. steup.sh
    2.1) removed -o pipefail. This is not standard posix, and as such will fail on strict posix shells. As there is no pipes in this script it is safe to remove
    2.2) added -I "$ROOT" so clang can find all the headers it needs
  3. updated highlights.scm to match grammar.js so it no longer crashes on loading a .carbon file

… the treesitter querys to the ref keyword from addr.
@pyqt555
pyqt555 requested a review from a team as a code owner July 4, 2026 05:34
@pyqt555
pyqt555 requested review from geoffromer and removed request for a team July 4, 2026 05:34
@github-actions github-actions Bot added the utilities Utilities for working with Carbon code: syntax highlighting, editor plugins, etc. label Jul 4, 2026

@chandlerc chandlerc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for trying to fix up stuff with the neovim support!

I wonder if we want to keep building the tree-sitter integration as part of this, or just focus on using the language server we have now... But a comment inline for now.

Comment thread utils/nvim/setup.sh
cd utils/tree_sitter
tree-sitter generate
clang -o ~/.config/nvim/parser/carbon.so -shared src/parser.c src/scanner.c -I ./src -Os -fPIC
clang -o ~/.config/nvim/parser/carbon.so -shared src/parser.c src/scanner.c -I "$ROOT" -I ./src -Os -fPIC

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's strange that we create the $ROOT variable above, but here we just did cd utils/tree_sitter, and before that we used $PWD. Should we instead set ROOT to $PWD, and do that just before the cd to make it clear this is so we can add -I pointing back at the root of the repo?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

After further concideration i think it would actually be better practice to set $ROOT to 2 levels up from $0,
(like this for example:
SCRIPT_DIR="$(cd -- "$(dirname -- "$0")" && pwd)"
ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)"
)
and just update every path pointing inside the repo to something like this:
"${ROOT}/utils/tree_sitter/queries"
this would allow the script to be executed form anywhere, even outside the repo.
Should i implement this or do you think there is a better way?

@zygoloid
zygoloid requested a review from chandlerc July 6, 2026 17:09
@geoffromer
geoffromer removed their request for review July 6, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

utilities Utilities for working with Carbon code: syntax highlighting, editor plugins, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants