mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 19:05:00 +01:00
As I was starting to try to play around with carbon, I wanted nvim integration. Unfortunately, a lot of the code in the integration had bitrotted, but not unbearably so, so I updated it 😄 It works now! Syntax highlighting and the LSP work out of the box with nvim 0.12 (and should also work on nvim 0.11) Hopefully all good that I did All The Commits, I come from the school of "every commit should do one thing" Closes #7821 --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
27 lines
754 B
Lua
27 lines
754 B
Lua
-- Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
-- Exceptions. See /LICENSE for license information.
|
|
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
vim.filetype.add({
|
|
extension = {
|
|
carbon = 'carbon',
|
|
},
|
|
})
|
|
vim.treesitter.language.add("carbon")
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
pattern = { 'carbon' },
|
|
callback = function() vim.treesitter.start() end,
|
|
})
|
|
|
|
-- LSP
|
|
function find_git_ancestor(startpath)
|
|
return vim.fs.dirname(vim.fs.find('.git', { path = startpath, upward = true })[1])
|
|
end
|
|
local root = find_git_ancestor(vim.env.PWD);
|
|
|
|
vim.lsp.config("carbon", {
|
|
cmd = { root .. "/bazel-bin/toolchain/carbon", "language-server" },
|
|
filetypes = { "carbon" },
|
|
})
|
|
vim.lsp.enable("carbon")
|