Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions lua/config/options.lua
Original file line number Diff line number Diff line change
@@ -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", {
Expand Down
119 changes: 119 additions & 0 deletions lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
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<string, vim.lsp.Config>
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 = {}
-- 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,
}
16 changes: 8 additions & 8 deletions setup/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down