From c48439ca8ff1eaa2b5defdc758275b8c0b1c5b91 Mon Sep 17 00:00:00 2001 From: weightofcode Date: Sun, 29 Mar 2026 20:25:12 +0300 Subject: [PATCH 1/2] initial commmit for LSP --- lua/plugins/lsp.lua | 118 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 lua/plugins/lsp.lua diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..e796674 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,118 @@ +return { + -- For description of the code below, check Kickstart Nvim on GitHub + -- As this is a copy-paste from there (and adapted) + 'neovim/nvim-lspconfig', + dependencies = { + { + 'mason-org/mason.nvim', + opts = {}, + }, + 'mason-org/mason-lspconfig.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + { 'j-hui/fidget.nvim', opts = {} }, + }, + config = function() + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + map('grn', vim.lsp.buf.rename, '[R]e[n]ame') + map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) + map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client:supports_method('textDocument/documentHighlight', event.buf) then + local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } + end, + }) + end + end, + }) + + -- Enable the following language servers + -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. + -- See `:help lsp-config` for information about keys and how to configure + -- @type table + local servers = { + -- clangd = {}, + -- gopls = {}, + pyright = {}, + -- rust_analyzer = {}, + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`ts_ls`) will work just fine + -- ts_ls = {}, + + stylua = {}, -- Used to format Lua code + + -- Special Lua Config, as recommended by neovim help docs + lua_ls = { + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + version = 'LuaJIT', + path = { 'lua/?.lua', 'lua/?/init.lua' }, + }, + workspace = { + checkThirdParty = false, + -- NOTE: this is a lot slower and will cause issues when working on your own configuration. + -- See https://github.com/neovim/nvim-lspconfig/issues/3189 + library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), { + '${3rd}/luv/library', + '${3rd}/busted/library', + }), + }, + }) + end, + settings = { + Lua = {}, + }, + }, + } + + -- Ensure the servers and tools above are installed + -- + -- To check the current status of installed tools and/or manually install + -- other tools, you can run + -- :Mason + -- + -- You can press `g?` for help in this menu. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + -- You can add other tools here that you want Mason to install + }) + + require('mason-tool-installer').setup { ensure_installed = ensure_installed } + + for name, server in pairs(servers) do + vim.lsp.config(name, server) + vim.lsp.enable(name) + end + end, +} From 8d81b4b8b6338b1bcd1377e0b505328e474939e1 Mon Sep 17 00:00:00 2001 From: weightofcode Date: Mon, 30 Mar 2026 22:36:37 +0300 Subject: [PATCH 2/2] remove lsp clutter, add clangd lsp, fix setup.sh --- lua/config/options.lua | 47 +++++++++++++++++++----------------- lua/plugins/lsp.lua | 55 +++++++++++++++++++++--------------------- setup/setup.sh | 16 ++++++------ 3 files changed, 61 insertions(+), 57 deletions(-) diff --git a/lua/config/options.lua b/lua/config/options.lua index b1ce118..2267c1f 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -1,34 +1,37 @@ -- --------------------------------------- -- Basic General Configuration -- --------------------------------------- -vim.opt.expandtab = true -- convert tabs to spaces -vim.opt.shiftwidth = 4 -- amount to indent with << and >> -vim.opt.tabstop = 4 -- number of spaces in one Tab -vim.opt.softtabstop = 4 -- number of spaces applied when pressing Tab -vim.opt.smarttab = true -- delete one Tab at once, not individual spaces -vim.opt.smartindent = true -- more or less as above, but when pressing CR -vim.opt.autoindent = true -- keep indentation from the previous line -vim.opt.breakindent = true -- break indent when line is longer than screen space - -vim.opt.number = true -- line number -vim.opt.cursorline = true -- highlight cursor line - -vim.opt.undofile = true -- store undo between sessions -vim.opt.mouse = "a" -- enable mouse -vim.opt.showmode = false -- don't show the mode, it's already in the statusline - -vim.opt.ignorecase = true -- case-insensitive search + +vim.opt.termguicolors = false -- attempt to use terminal colors instead of colorschemes + +vim.opt.expandtab = true -- convert tabs to spaces +vim.opt.shiftwidth = 4 -- amount to indent with << and >> +vim.opt.tabstop = 4 -- number of spaces in one Tab +vim.opt.softtabstop = 4 -- number of spaces applied when pressing Tab +vim.opt.smarttab = true -- delete one Tab at once, not individual spaces +vim.opt.smartindent = true -- more or less as above, but when pressing CR +vim.opt.autoindent = true -- keep indentation from the previous line +vim.opt.breakindent = true -- break indent when line is longer than screen space + +vim.opt.number = true -- line number +vim.opt.cursorline = true -- highlight cursor line + +vim.opt.undofile = true -- store undo between sessions +vim.opt.mouse = "a" -- enable mouse +vim.opt.showmode = false -- don't show the mode, it's already in the statusline + +vim.opt.ignorecase = true -- case-insensitive search vim.opt.smartcase = true -- case-sensitive search if a Capital letter is inserted -vim.opt.signcolumn = "yes" -- vertical column for utils (warning, error, etc.) next to line num +vim.opt.signcolumn = "yes" -- vertical column for utils (warning, error, etc.) next to line num -vim.opt.splitright = true -- make split to the right intuitive -vim.opt.splitbelow = true -- make split below intuitive +vim.opt.splitright = true -- make split to the right intuitive +vim.opt.splitbelow = true -- make split below intuitive -vim.opt.list = true -- display special characters +vim.opt.list = true -- display special characters vim.opt.listchars = { tab = "≫ ", trail = "·", nbsp = "␣" } -vim.opt.scrolloff = 5 -- minimum number of lines to keep above and below the cursor +vim.opt.scrolloff = 5 -- minimum number of lines to keep above and below the cursor -- highlight yanked text for better visibility vim.api.nvim_create_autocmd("TextYankPost", { diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index e796674..7e6ea71 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -53,7 +53,7 @@ return { -- See `:help lsp-config` for information about keys and how to configure -- @type table local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, pyright = {}, -- rust_analyzer = {}, @@ -67,33 +67,34 @@ return { stylua = {}, -- Used to format Lua code -- Special Lua Config, as recommended by neovim help docs - lua_ls = { - on_init = function(client) - if client.workspace_folders then - local path = client.workspace_folders[1].name - if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end - end + lua_ls = {} + -- lua_ls = { + -- on_init = function(client) + -- if client.workspace_folders then + -- local path = client.workspace_folders[1].name + -- if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end + -- end - client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { - runtime = { - version = 'LuaJIT', - path = { 'lua/?.lua', 'lua/?/init.lua' }, - }, - workspace = { - checkThirdParty = false, - -- NOTE: this is a lot slower and will cause issues when working on your own configuration. - -- See https://github.com/neovim/nvim-lspconfig/issues/3189 - library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), { - '${3rd}/luv/library', - '${3rd}/busted/library', - }), - }, - }) - end, - settings = { - Lua = {}, - }, - }, + -- client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + -- runtime = { + -- version = 'LuaJIT', + -- path = { 'lua/?.lua', 'lua/?/init.lua' }, + -- }, + -- workspace = { + -- checkThirdParty = false, + -- -- NOTE: this is a lot slower and will cause issues when working on your own configuration. + -- -- See https://github.com/neovim/nvim-lspconfig/issues/3189 + -- library = vim.tbl_extend('force', vim.api.nvim_get_runtime_file('', true), { + -- '${3rd}/luv/library', + -- '${3rd}/busted/library', + -- }), + -- }, + -- }) + -- end, + -- settings = { + -- Lua = {}, + -- }, + -- }, } -- Ensure the servers and tools above are installed diff --git a/setup/setup.sh b/setup/setup.sh index f0c1086..5296255 100644 --- a/setup/setup.sh +++ b/setup/setup.sh @@ -4,15 +4,15 @@ echo "NVIM_CONFIG_INFO: Running Unix setup..." # package manager >>>>>>>> if command -v apt >/dev/null 2>&1; then - PKG_MANAGER = "apt" + PKG_MANAGER="apt" elif command -v pacman >/dev/null 2>&1; then - PKG_MANAGER = "pacman" + PKG_MANAGER="pacman" elif command -v dnf >/dev/null 2>&1; then - PKG_MANAGER = "dnf" + PKG_MANAGER="dnf" elif command -v brew >/dev/null 2>&1; then - PKG_MANAGER = "brew" + PKG_MANAGER="brew" elif command -v pkg >/dev/null 2>&1; then - PKG_MANAGER = "pkg" + PKG_MANAGER="pkg" else echo "NVIM_SETUP_ERROR: No supported package manager found." exit 1 @@ -22,11 +22,11 @@ echo "NVIM_SETUP_ERROR: Detected package manager: $PKG_MANAGER" # install Neovim >>>>>>>> install_package() { - pkg_name = $1 - case $PKG_MANAGER in + pkg_name="$1" + case $PKG_MANAGER in apt) sudo apt update - sudp apt install -y "$pkg_name" + sudo apt install -y "$pkg_name" ;; pacman) sudo pacman -Sy --noconfirm "$pkg_name"