Skip to content

Commit

Permalink
feat(neovim): add support for C/C++, Lua, Rust, and Java
Browse files Browse the repository at this point in the history
Add completion support using Neovim's built-in LSP client. Add documentations
for installing language servers. Add highlighting support based on Tree-sitter.
Configure Tree-sitter parsers and language servers.

https://github.com/mfussenegger/nvim-jdtls#configuration-quickstart
LuaLS/lua-language-server#1788 (comment)
  • Loading branch information
clavia-lang committed Jan 19, 2025
1 parent 5ccc088 commit 2ea0b92
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Neovim

Neovim has a built-in LSP client. There are several language servers used in the
configurations.

Language | Language Server | Installation
-------- | ------------------------------------ | ------------------------------
C/C++ | [clangd] | [Installation][install_clangd]
Lua | [lua-language-server][luals] | [Installation][install_luals]
Rust | [rust-analyzer][rls2] | [Installation][install_rls2]
Java | [Eclipse JDT Language Server][jdtls] | [Installation][install_jdtls]

[clangd]: https://github.com/clangd/clangd
[install_clangd]: https://clangd.llvm.org/installation#installing-clangd
[luals]: https://github.com/LuaLS/lua-language-server
[install_luals]: https://luals.github.io/#neovim-install
[rls2]: https://github.com/rust-lang/rust-analyzer
[install_rls2]: https://rust-analyzer.github.io/manual.html#installation
[jdtls]: https://github.com/eclipse-jdtls/eclipse.jdt.ls
[install_jdtls]: https://github.com/eclipse-jdtls/eclipse.jdt.ls#installation

```console
$ sudo pacman -S clangd rust-analyzer lua-language-server
$ paru -S jdtls
```
5 changes: 5 additions & 0 deletions neovim/.config/nvim/ftplugin/java.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
local jdtls = require("jdtls")
jdtls.start_or_attach({
cmd = { "jdtls" },
root_dir = vim.fs.dirname(vim.fs.find({ "gradlew", ".git", "mvnw", { upward = true }})[1])
})
9 changes: 9 additions & 0 deletions neovim/.config/nvim/lua/plugins/cmp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local cmp = require("cmp")
cmp.setup({
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
}),
})
15 changes: 15 additions & 0 deletions neovim/.config/nvim/lua/plugins/lspconfig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local lspconfig = require("lspconfig")
lspconfig.clangd.setup({})
lspconfig.lua_ls.setup({
settings = {
Lua = {
workspace = {
library = vim.tbl_extend(
"keep",
{ "/usr/lib/lua-language-server/meta/template" },
vim.api.nvim_get_runtime_file("", true)
),
},
},
},
})
15 changes: 15 additions & 0 deletions neovim/.config/nvim/rocks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@
"rocks-git.nvim" = "1.1.1"
"rocks-config.nvim" = "3.1.0"
"rocks-lazy.nvim" = "1.1.1"

nvim-lspconfig = "1.3.0"
nvim-cmp = "scm"
cmp-nvim-lsp = "scm"
rustaceanvim = "5.22.0"
nvim-jdtls = "0.2.0"

tree-sitter-c = "0.0.36"
tree-sitter-cpp = "0.0.35"
tree-sitter-rust = "0.0.38"
tree-sitter-java = "0.0.37"
tree-sitter-lua = "0.0.32"

[plugins.nvim-treesitter]
git = "nvim-treesitter/nvim-treesitter"

0 comments on commit 2ea0b92

Please sign in to comment.