From 3e851969feac3b32a42a85326a1e656e62803143 Mon Sep 17 00:00:00 2001 From: thom Date: Wed, 29 Apr 2026 16:03:49 +0200 Subject: [PATCH] added LSP config for C, CPP, rust and zig. --- init.lua | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 13727202e80..e653ed3f5a8 100644 --- a/init.lua +++ b/init.lua @@ -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 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