Compare commits

...

10 Commits

7 changed files with 341 additions and 1 deletions

View File

@ -1,2 +1,16 @@
--
-- Initialize Neovim configuration
-- ..............................................
--
-- Author: Sven Vogel
-- Created: 01.11.2024
-- Edited: 01.11.2024
--
-- ==============================================
-- Load plugin manager
-- and plugins, additonally setup global options
require("config.lazy")
require("config.opts")
-- install custom keymaps
require("config.keys")

156
lua/config/keys.lua Normal file
View File

@ -0,0 +1,156 @@
--
-- Global custom plugin agnostic keymaps
-- ..............................................
--
-- Author: Sven Vogel
-- Created: 01.11.2024
-- Edited: 01.11.2024
--
-- ==============================================
local keymaps = {
--
-- Write buffer to disk
-- ..............................................
{
mode = { 'n', 'i' },
keys = '<C-s>',
cmd = vim.cmd.write,
desc = "Write buffer to disk"
},
{
mode = { 'n', 'i' },
keys = '<C-z>',
cmd = vim.cmd.undo,
desc = "Undo last edit"
},
{
mode = { 'n', 'i' },
keys = '<C-y>',
cmd = vim.cmd.redo,
desc = "Redo last edit that was undone"
},
--
-- Shift line(s) by one shiftwidth
-- ..............................................
{
mode = { 'n', 'i' },
keys = '<S-tab>',
cmd = '<cmd>:<<cr>',
desc = "Shift cursor line left"
},
{
mode = { 'n', 'i' },
keys = '<tab>',
cmd = '<cmd>:><cr>',
desc = "Shift cursor line right"
},
{
mode = { 'v' },
keys = '<tab>',
cmd = '>gv',
desc = "Shift selection in visual mode right"
},
{
mode = { 'v' },
keys = '<S-tab>',
cmd = '<gv',
desc = "Shift selection in visual right"
},
--
-- Buffer management
-- ..............................................
{
mode = { 'n', 'i' },
keys = '<C-t>',
cmd = '<cmd>:enew<cr>',
desc = "Edit new, unnamed buffer"
},
--
-- Window controls
-- ..............................................
{
mode = { 'n', 'i' },
keys = '<C-w>v',
cmd = '<cmd>:vsplit<cr>',
desc = "Split window vertically"
},
{
mode = { 'n', 'i' },
keys = '<C-w>h',
cmd = '<cmd>:split<cr>',
desc = "Split window horizontally"
},
{
mode = { 'n' },
keys = 'q',
cmd = function()
-- list of file types to ignore when counting split buffers
local ignore = { "neo-tree" }
-- number of windows per tab
local wins = vim.api.nvim_tabpage_list_wins(0)
-- count of open windows without those on ignore list
local count = 0
-- check each window for its type
for _, win in ipairs(wins) do
local buf = vim.api.nvim_win_get_buf(win)
local buf_type = vim.api.nvim_buf_get_option(buf, 'buftype')
local file_type = vim.api.nvim_buf_get_option(buf, 'filetype')
if buf_type == '' then
-- check if buffer is in ignore
in_ignore = false
for _, v in ipairs(ignore) do
if v == file_type then
in_ignore = true
break
end
end
if not in_ignore then
count = count + 1
end
end
end
if count == 1 then
-- only one buffer without any split
-- account for barbar specific behavior
vim.cmd('BufferClose')
else
-- close window
vim.cmd('q')
end
end,
desc = "Close buffer"
},
--
-- Tab (barbar) controls
-- ..............................................
{
mode = { 'n', 'i' },
keys = '<C-tab>',
cmd = vim.cmd('BufferNext'),
desc = "Switch to the next buffer"
},
{
mode = { 'n', 'i' },
keys = '<C-S-tab>',
cmd = vim.cmd('BufferPrevious'),
desc = "Switch to the previous buffer"
}
}
for _, keymap in pairs(keymaps) do
local mode = keymap.mode
local lhs = keymap.keys
local rhs = keymap.cmd
local opts = {
desc = keymap.desc,
noremap = keymap.noremap
}
vim.keymap.set(mode, lhs, rhs, opts)
end

View File

@ -1,3 +1,19 @@
--
-- Bootstrap and start Lazy.nvim plugins
-- manager.
-- ..............................................
--
-- Author: Sven Vogel
-- Created: 01.11.2024
-- Edited: 01.11.2024
--
-- ==============================================
--
-- Bootstrap Lazy.nvim package manager
-- ..............................................
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
@ -15,12 +31,23 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)
--
-- Early setup of Neovim and VIM options
-- ..............................................
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- load options
require("config.opts")
--
-- Start Lazy.nvim
-- ..............................................
-- Setup lazy.nvim
require("lazy").setup({
spec = {
@ -32,4 +59,17 @@ require("lazy").setup({
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = false },
rtp = {
disabled_plugins = {
"gzip",
"matchit",
"matchparen",
"netrw",
"netrwplugin",
"tarplugin",
"tohtml",
"tutor",
"zipplugin",
}
},
})

View File

@ -1,3 +1,19 @@
--
-- Neovim and VIM global configuration
-- and options
-- ..............................................
--
-- Author: Sven Vogel
-- Created: 01.11.2024
-- Edited: 01.11.2024
--
-- ==============================================
--
-- neovim global options
-- ..............................................
local opt = vim.opt
opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard
@ -14,3 +30,14 @@ opt.termguicolors = true -- True color support
opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode
opt.wrap = false
opt.smoothscroll = true
opt.swapfile = false -- disable swapfiles because they are fucking garbage
opt.smartindent = true
--
-- VIM global options
-- ..............................................
-- disable netrw
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

22
lua/plugins/barbar.lua Normal file
View File

@ -0,0 +1,22 @@
return {
{
'romgrk/barbar.nvim',
dependencies = {
'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status
'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons
},
init = function()
vim.g.barbar_auto_setup = false
end,
opts = {
auto_hide = 1,
tabpages = true,
clickable = true,
-- Set the filetypes which barbar will offset itself for
sidebar_filetypes = {
['neo-tree'] = {event = 'BufWipeout'}
}
},
version = '^1.0.0'
}
}

View File

@ -0,0 +1,19 @@
--
-- Global custom plugin agnostic keymaps
--
-- Source: https://github.com/Eandrju/cellular-automaton.nvim
-- ..............................................
--
-- Author: Sven Vogel
-- Created: 01.11.2024
-- Edited: 01.11.2024
--
-- ==============================================
return {
{
'eandrju/cellular-automaton.nvim'
}
}

62
lua/plugins/neo-tree.lua Normal file
View File

@ -0,0 +1,62 @@
return {
"nvim-neo-tree/neo-tree.nvim",
lazy = false,
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim"
},
cmd = "Neotree",
opts = {
source_selector = {
winbar = true,
statusline = false,
sources = {
{
source = "filesystem",
display_name = " 󰉓 Files "
},
{
source = "buffers",
display_name = " 󰈚 Buffers "
},
{
source = "document_symbols",
display_name = " 󰊢 Git "
},
},
},
filesystem = {
bind_to_cwd = false,
follow_current_file = { enabled = true },
use_libuv_file_watcher = true,
hijack_netrw_behavior = "open_default",
filtered_items = {
hide_dotfiles = false,
hide_gitignored = false,
hide_hidden = false, -- only works on Windows for hidden files/directories
},
window = {
position = "left"
}
},
close_if_last_window = false,
default_component_configs = {
container = {
enable_character_fade = true
},
indent = {
indent_size = 2,
padding = 1, -- extra padding on left hand side
with_markers = true,
indent_marker = "",
last_indent_marker = "",
with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
}
}
}
}