Add some more configs

This commit is contained in:
risitas@plancha 2023-05-19 16:01:11 +02:00
parent 243e4fb669
commit 8fb0bec563
4 changed files with 383 additions and 0 deletions

View File

@ -5,3 +5,6 @@ tmux
exa
trash-cli
bat
gcc
cmake
g++

View File

@ -0,0 +1,261 @@
---------------------
-- Setup lazy.nvim --
---------------------
cfg_root = vim.fn.stdpath("config")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- We need to set this before lazy so our mappings are set
vim.g.mapleader = " "
-- enable hex colors. This needs to come before plugins, because
-- some (like cmp) will render ugly colors else
vim.opt.termguicolors = true
-------------
-- Plugins --
-------------
require("lazy").setup({
-- Gruvbox colorscheme
{
"morhetz/gruvbox",
init = function()
vim.cmd [[colorscheme gruvbox]]
end
},
-- Lualine statusline
{
"hoob3rt/lualine.nvim",
opts = {
options = {
component_separators = {"", ""},
section_separators = {"", ""},
}
},
dependencies = {"kyazdani42/nvim-web-devicons"}
},
-- treesitter
{
"nvim-treesitter/nvim-treesitter",
dependencies = {
'windwp/nvim-ts-autotag'
},
init = function ()
require'nvim-treesitter.configs'.setup {
ensure_installed = {"c", "lua", "rust", "markdown", "yaml", "bash"},
highlight = {
enable = true,
},
autotag = {
enable = true,
}
}
end
},
-- LSP (completion, diagnostics, etc)
{
"neovim/nvim-lspconfig",
init = function ()
local lspconfig = require("lspconfig")
local servers = {"pyright", "bashls", "jsonls", "lua_ls", "yamlls"}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup{
capabilities = require("cmp_nvim_lsp").default_capabilities(),
}
end
end
},
-- cmp (autocomplete)
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
},
init = function ()
local cmp = require("cmp")
local luasnip = require("luasnip")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump()
else fallback() end
end, {"i", "s"}),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
},
})
end
},
-- Luasnip (snippets)
"L3MON4D3/LuaSnip",
-- trouble: show errors with :Trouble
{
'folke/trouble.nvim',
init = function ()
require("which-key").register({
["<space>t"] = { ":TroubleToggle<cr>", "Open/close Trouble" },
})
end
},
-- which-key: shortcuts
{
"folke/which-key.nvim",
init = function ()
vim.o.timeout = true
vim.o.timeoutlen = 300
local wk = require('which-key')
wk.setup{}
wk.register({
["<space>"] = {
w = { ":w<cr>", "Save" },
q = { ":q<cr>", "Quit" },
}
})
end
},
-- Telescope: fuzzy finder
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-lua/popup.nvim",
},
init = function()
local telescope = require("telescope")
require("which-key").register({
["<space>f"] = {
name = "Find",
f = {"<cmd>Telescope find_files<cr>", "Find files"},
g = {"<cmd>Telescope live_grep<cr>", "Find in files"},
b = {"<cmd>Telescope buffers<cr>", "Find buffers"},
h = {"<cmd>Telescope help_tags<cr>", "Find help"},
}
})
end
},
-- NvimTree: file explorer
{
"nvim-tree/nvim-tree.lua",
init = function ()
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
require("which-key").register({
["<space>e"] = { ":NvimTreeToggle<cr>", "Open/close NvimTree" },
})
end,
opts = {}
},
-- change project root to git root
"airblade/vim-rooter",
-- Git helper
{
"tpope/vim-fugitive",
init = function ()
require("which-key").register({
["<space>g"] = {
name = "Git",
c = { "<cmd>Git commit<cr>", "Commit" },
a = { "<cmd>Git add " .. vim.fn.expand('%:p') .. "<cr>", "Stage current file" },
A = { "<cmd>Git add --patch " .. vim.fn.expand('%:p') .. "<cr>", "Stage current file selectively" },
u = { "<cmd>Git restore --staged " .. vim.fn.expand('%:p') .. "<cr>", "Unstage current file" },
p = { "<cmd>Git push<cr>", "Push" },
s = { "<cmd>Git status<cr>", "Status" },
d = { "<cmd>Git diff<cr>", "Diff" },
r = { "<cmd>Git restore ".. vim.fn.expand('%:p') .."<cr>", "Restore current file" },
R = { "<cmd>Git restore --patch ".. vim.fn.expand('%:p') .."<cr>", "Restore current file selectively" },
}
})
end
},
-- Auto close brackets that aren't annoying (= closing already closed brackets)
{
"windwp/nvim-autopairs",
-- Actually call require("nvim-autopairs").setup()
opts = {}
},
-- Automatically add, change, and remove pairs of quotes, brackets, etc.
"tpope/vim-surround",
-- Easily comment/decomment code
"tpope/vim-commentary",
-- Automatically detect tab/space indentation
"tpope/vim-sleuth",
-- Fountain (screenplay magkup language) support
"kblin/vim-fountain",
-- Rust integration
{
"rust-lang/rust.vim",
init = function ()
vim.g.rustfmt_autosave = 1
end
},
})
------------------------
-- Additional options --
------------------------
-- Enable relative line numbers
vim.opt.number = true
vim.opt.relativenumber = true
-- Show gutter in line numbers
vim.opt.signcolumn = "number"
-- Disable those annoying swap files
vim.opt.swapfile = false
-- Store undo history between sessions
vim.opt.undofile = true
vim.opt.undodir = vim.fn.stdpath("cache") .. "/undo"
-- Set tab width to 4 spaces
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
-- Enable mouse support just in case I turn into a normie (magic!)
vim.opt.mouse = "a"
-- Enable system clipboard support
vim.opt.clipboard = "unnamedplus"
-- Word wrap
vim.opt.wrap = true
vim.opt.linebreak = true
-- Bind S to replace every occurence (normal mode)
vim.cmd [[map S :%s//g<Left><Left>]]

View File

@ -0,0 +1,26 @@
{
"LuaSnip": { "branch": "master", "commit": "ec7fba1d119fb5090a901eb616145450ffb95e31" },
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
"gruvbox": { "branch": "master", "commit": "bf2885a95efdad7bd5e4794dd0213917770d79b7" },
"lazy.nvim": { "branch": "main", "commit": "c711b4f8a6211a8ea3f3c35f0962ac0b6b8550cc" },
"lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" },
"nvim-autopairs": { "branch": "master", "commit": "7747bbae60074acf0b9e3a4c13950be7a2dff444" },
"nvim-cmp": { "branch": "main", "commit": "3ac8d6cd29c74ff482d8ea47d45e5081bfc3f5ad" },
"nvim-lspconfig": { "branch": "master", "commit": "6f1d124bbcf03c4c410c093143a86415f46d16a0" },
"nvim-tree.lua": { "branch": "master", "commit": "736c7ff59065275f0483af4b7f07a9bc41449ad0" },
"nvim-treesitter": { "branch": "master", "commit": "05df88ebaa94d30d682d076244615786d9e7c1a5" },
"nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" },
"nvim-web-devicons": { "branch": "master", "commit": "986875b7364095d6535e28bd4aac3a9357e91bbe" },
"plenary.nvim": { "branch": "master", "commit": "9ac3e9541bbabd9d73663d757e4fe48a675bb054" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" },
"telescope.nvim": { "branch": "master", "commit": "40c31fdde93bcd85aeb3447bb3e2a3208395a868" },
"trouble.nvim": { "branch": "main", "commit": "2173dffe91fc0914b3b833c6a2f6fe1d3fac2e17" },
"vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" },
"vim-fountain": { "branch": "master", "commit": "4464261ce6f173e5c2dab54b34a2860102c27d25" },
"vim-fugitive": { "branch": "master", "commit": "5f0d280b517cacb16f59316659966c7ca5e2bea2" },
"vim-rooter": { "branch": "master", "commit": "4f52ca556a0b9e257bf920658714470ea0320b7a" },
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"which-key.nvim": { "branch": "main", "commit": "5a6c954a5a46023c19acc03a8b6d7c3e57964fc5" }
}

View File

@ -0,0 +1,93 @@
#----------#
# Bindings #
#----------#
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Better splitting keys
unbind g
bind-key g split-window -h
unbind c
bind-key c split-window -v
# Reload config
bind-key r source-file ~/.config/tmux/tmux.conf
# Easier pane switching with Ctrl - home row keys
unbind n
bind n select-pane -L
unbind e
bind e select-pane -U
unbind i
bind i select-pane -D
unbind o
bind o select-pane -R
# Mouse mode
set -g mouse on
#---------#
# Options #
#---------#
# Delete the session when the last window is closed
# set -g detach-on-destroy on
# Longer history
set -g history-limit 100000
# Refresh status bar every 5 seconds
set -g status-interval 1
set -g default-terminal "screen-256color"
#------------#
# Status bar #
#------------#
# Basic options
set -g status-justify centre
set -g status-bg colour237
set -g status-fg colour15
set -g status-left-length 100
set -g status-right-length 50
set -g status-position top # because vim is on the bottom
# Main formatting strings
set -g status-left "#{@sis} #{T:@status-left-inner} #{@sms} #{T:@status-left-middle} #{@sos} #{T:@status-left-outer} "
set -g status-right "#{@sos} #{T:@status-right-outer} #{@sms} #{T:@status-right-middle} #{@sis} #{T:@status-right-inner} "
# Status bar styles
set -g @sos "#[bg=colour237,fg=colour15, nobold]" # status outer style
set -g @sms "#[bg=#504945, fg=#ebdbb2, nobold]" # status middle style
set -g @sis "#[bg=#a89984, fg=#282828, bold]" # status inner style
# Content
set -g @status-left-outer '#{T:@segment-docker-running-containers}#{T:@segment-docker-offline-containers}'
set -g @status-left-middle '#(echo #{pane_current_path} | sed "s|$HOME|~|g" | rev | cut -d "/" -f 1 | rev)'
set -g @status-left-inner '#{session_name}'
set -g @status-right-outer '#{T:@segment-git-all}'
set -g @status-right-middle '#{T:@segment-time}'
set -g @status-right-inner '#{T:@segment-who-and-where}'
set -g @segment-time "%H:%M"
set -g @segment-who-and-where "#{user}@#{host_short}"
# Git commands in a single segment
set -g @segment-git-all "#(cd #{pane_current_path}; [[ `git rev-parse --show-toplevel` ]] && echo -n ' ' && #{@command-git-branch} && #{@command-git-staged} && #{@command-git-unstaged} && #{@command-git-toplevel})"
set -g @command-git-branch "git rev-parse --abbrev-ref HEAD | tr -d '\n'"
set -g @command-git-staged "git diff --staged --numstat | awk '{s+=$1} END {print s}' | sed 's/^/ +/g' | grep -E '.{3,}' | tr -d '\n'"
set -g @command-git-unstaged "git diff --numstat | awk '{s+=$1} END {print s}' | sed 's/^/ ~/g' | grep -E '.{3,}' | tr -d '\n'"
set -g @command-git-toplevel "git rev-parse --show-toplevel | grep -E '.{1,}' | rev | cut -d '/' -f 1 | rev | sed 's/^/ /g' | tr -d '\n'"
set -g @segment-docker-running-containers "#(docker ps --format '{{.Names}}' | sed 's/^/ /g' | sed 's/$/ /g' | grep -E '.{1,}' | tr -d '\n')"
set -g @segment-docker-offline-containers "#(docker ps -a --format '{{.Names}}' | grep -vf <(docker ps --format '{{.Names}}') | sed 's/^/ /g' | sed 's/$/ /g' | grep -E '.{1,}' | tr -d '\n')"
set -g set-titles-string "#{pane_title} "