added LSP config for C, CPP, rust and zig.

This commit is contained in:
thom 2026-04-29 16:03:49 +02:00
parent 9b4fbc5021
commit 3e851969fe
1 changed files with 27 additions and 4 deletions

View File

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true
-- [[ Setting options ]]
-- See `:help vim.o`
@ -119,6 +119,11 @@ vim.schedule(function() vim.o.clipboard = 'unnamedplus' end)
-- Enable break indent
vim.o.breakindent = true
-- NOTE: my config here. Sets tab and space width to 4, and uses spaces instead of tab chars.
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
-- Enable undo/redo changes even after closing and reopening a file
vim.o.undofile = true
@ -258,6 +263,16 @@ require('lazy').setup({
-- NOTE: Plugins can be added via a link or github org/name. To run setup automatically, use `opts = {}`
{ 'NMAC427/guess-indent.nvim', opts = {} },
-- NOTE: my inclusion of autopairs plugin here
{
'windwp/nvim-autopairs',
event = "InsertEnter",
config = function()
local autopairs = require('nvim-autopairs')
autopairs.setup({})
end,
},
-- Alternatively, use `config = function() ... end` for full control over the configuration.
-- If you prefer to call `setup` explicitly, use:
-- {
@ -600,10 +615,13 @@ require('lazy').setup({
-- See `:help lsp-config` for information about keys and how to configure
---@type table<string, vim.lsp.Config>
local servers = {
-- clangd = {},
clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
rust_analyzer = {},
zls = {
cmd = { '/usr/local/bin/zls' },
},
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
@ -656,6 +674,11 @@ require('lazy').setup({
--
-- You can press `g?` for help in this menu.
local ensure_installed = vim.tbl_keys(servers or {})
-- remove ZLS from the mason install list
ensure_installed = vim.tbl_filter(function(name)
return name ~= 'zls'
end, ensure_installed)
vim.list_extend(ensure_installed, {
-- You can add other tools here that you want Mason to install
})
@ -889,7 +912,7 @@ require('lazy').setup({
-- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
config = function()
-- ensure basic parser are installed
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
local parsers = { 'bash', 'c', 'cpp', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'zig' }
require('nvim-treesitter').install(parsers)
---@param buf integer