summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--after/plugin/autoclose.lua20
-rw-r--r--after/plugin/gitsigns.lua21
-rw-r--r--after/plugin/harpoon.lua33
-rw-r--r--after/plugin/mini.lua14
-rw-r--r--after/plugin/telescope.lua38
-rw-r--r--after/plugin/treesitter.lua10
-rw-r--r--after/plugin/vim-tmux-navigator.lua6
-rw-r--r--init.lua1
-rw-r--r--lua/user/init.lua31
-rw-r--r--lua/user/lazy.lua103
-rw-r--r--lua/user/map.lua78
-rw-r--r--lua/user/set.lua96
-rw-r--r--templates/c.make4
14 files changed, 457 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..24258b7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+lazy-lock.json
+spell
diff --git a/after/plugin/autoclose.lua b/after/plugin/autoclose.lua
new file mode 100644
index 0000000..89078ef
--- /dev/null
+++ b/after/plugin/autoclose.lua
@@ -0,0 +1,20 @@
+require("autoclose").setup({
+ keys = {
+ ["("] = { escape = false, close = true, pair = "()"},
+ ["["] = { escape = false, close = true, pair = "[]"},
+ ["{"] = { escape = false, close = true, pair = "{}"},
+
+ [">"] = { escape = true, close = false, pair = "<>"},
+ [")"] = { escape = true, close = false, pair = "()"},
+ ["]"] = { escape = true, close = false, pair = "[]"},
+ ["}"] = { escape = true, close = false, pair = "{}"},
+
+ ['"'] = { escape = true, close = true, pair = '""'},
+ ["'"] = { escape = true, close = true, pair = "''"},
+ ["`"] = { escape = true, close = true, pair = "``"},
+ },
+ options = {
+ disabled_filetypes = { "text", "telekasten", "groff", "diff", "gitcommit", "fugitive" },
+ disable_when_touch = true,
+ },
+})
diff --git a/after/plugin/gitsigns.lua b/after/plugin/gitsigns.lua
new file mode 100644
index 0000000..e7ab463
--- /dev/null
+++ b/after/plugin/gitsigns.lua
@@ -0,0 +1,21 @@
+require("gitsigns").setup({
+ signs = {
+ add = { text = "▎" },
+ change = { text = "▎" },
+ delete = { text = "▎" },
+ topdelete = { text = "▎" },
+ changedelete = { text = "▎" },
+ untracked = { text = "▎" },
+ },
+ on_attach = function(buffer)
+ local gs = package.loaded.gitsigns
+
+ local function map(mode, l, r, desc)
+ vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
+ end
+
+ -- stylua: ignore start
+ map("n", "]g", gs.next_hunk, "Next git hunk")
+ map("n", "[g", gs.prev_hunk, "Previous git hunk")
+ end,
+})
diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua
new file mode 100644
index 0000000..bd5aeef
--- /dev/null
+++ b/after/plugin/harpoon.lua
@@ -0,0 +1,33 @@
+local harpoon = require("harpoon")
+
+-- REQUIRED
+harpoon:setup()
+-- REQUIRED
+
+vim.keymap.set("n", "<leader>a", function()
+ harpoon:list():append()
+end, { desc = "Append file to harpoon starred list" })
+vim.keymap.set("n", "<C-e>", function()
+ harpoon.ui:toggle_quick_menu(harpoon:list())
+end, { desc = "Check the list of files in harpoon" })
+
+vim.keymap.set("n", "<C-j>", function()
+ harpoon:list():select(1)
+end, { desc = "Harpoon to 1st file in list" })
+vim.keymap.set("n", "<C-k>", function()
+ harpoon:list():select(2)
+end, { desc = "Harpoon to 2nd file in list" })
+vim.keymap.set("n", "<C-l>", function()
+ harpoon:list():select(3)
+end, { desc = "Harpoon to 3rd file in list" })
+vim.keymap.set("n", "<C-;>", function()
+ harpoon:list():select(4)
+end, { desc = "Harpoon to 4th file in list" })
+
+-- Toggle previous & next buffers stored within Harpoon list
+vim.keymap.set("n", "<C-S-J>", function()
+ harpoon:list():prev()
+end, { desc = "Harpoon to previous file in list" })
+vim.keymap.set("n", "<C-S-K>", function()
+ harpoon:list():next()
+end, { desc = "Harpoon to next file in list" })
diff --git a/after/plugin/mini.lua b/after/plugin/mini.lua
new file mode 100644
index 0000000..d695a5a
--- /dev/null
+++ b/after/plugin/mini.lua
@@ -0,0 +1,14 @@
+-- Setup my mini.nvim settings
+-- mini.nvim is amazing because it add's a lot of functionality while keeping itself as minimal as possible
+-- because of it's modular nature and fact it has a lot of functionality it lower the amount of needed plugins even for advanced features
+
+-- mini.nvim statusline module
+require("mini.statusline").setup({
+ set_vim_settings = false,
+})
+
+-- mini.nvim commeting module
+require("mini.comment").setup({})
+
+-- mini.nvim surround module
+require("mini.surround").setup({})
diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua
new file mode 100644
index 0000000..55e9586
--- /dev/null
+++ b/after/plugin/telescope.lua
@@ -0,0 +1,38 @@
+require('telescope').setup({
+ defaults = {
+ path_display = {
+ shorten = {
+ len = 3, exclude = {1, -1}
+ },
+ truncate = true
+ },
+ dynamic_preview_title = true,
+ },
+ extensions = {
+ ["ui-select"] = {
+ require("telescope.themes").get_dropdown({}),
+ },
+ ["fzf"] = {
+ fuzzy = true,
+ override_generic_sorter = true,
+ override_file_sorter = true,
+ case_mode = "smart_case",
+ },
+ },
+})
+
+local builtin = require('telescope.builtin')
+vim.keymap.set('n', '<leader>ff', builtin.find_files)
+vim.keymap.set('n', '<leader>fb', builtin.buffers)
+vim.keymap.set('n', '<leader>fg', builtin.git_files)
+vim.keymap.set('n', '<leader>fw', builtin.live_grep)
+vim.keymap.set("n", "<C-p>", "<cmd>Telescope git_files<cr>", { desc = "Find git files" })
+vim.keymap.set("n", "<leader>vh", builtin.help_tags, { desc = "Find help tags" })
+
+-- symbols
+vim.keymap.set("n", "<leader>tse", "<cmd>lua require'telescope.builtin'.symbols{ sources = {'emoji', 'gitmoji'} }<CR>")
+vim.keymap.set("n", "<leader>tsn", "<cmd>lua require'telescope.builtin'.symbols{ sources = {'nerd'} }<CR>")
+vim.keymap.set("n", "<leader>tsj", "<cmd>lua require'telescope.builtin'.symbols{ sources = {'julia'} }<CR>")
+
+require("telescope").load_extension("ui-select")
+require("telescope").load_extension("fzf")
diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua
new file mode 100644
index 0000000..1eb6fa5
--- /dev/null
+++ b/after/plugin/treesitter.lua
@@ -0,0 +1,10 @@
+require("nvim-treesitter.configs").setup({
+ ensure_installed = { "lua", "bash" },
+ sync_install = false,
+ auto_install = true,
+
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = false,
+ },
+})
diff --git a/after/plugin/vim-tmux-navigator.lua b/after/plugin/vim-tmux-navigator.lua
new file mode 100644
index 0000000..c7042fd
--- /dev/null
+++ b/after/plugin/vim-tmux-navigator.lua
@@ -0,0 +1,6 @@
+vim.cmd("let g:tmux_navigator_no_mappings = 1")
+vim.keymap.set("n", "<M-h>", ":<C-U>TmuxNavigateLeft<cr>", {silent = true})
+vim.keymap.set("n", "<M-j>", ":<C-U>TmuxNavigateDown<cr>", {silent = true})
+vim.keymap.set("n", "<M-k>", ":<C-U>TmuxNavigateUp<cr>", {silent = true})
+vim.keymap.set("n", "<M-l>", ":<C-U>TmuxNavigateRight<cr>", {silent = true})
+vim.keymap.set("n", "<M-/>", ":<C-U>TmuxNavigatePrevious<cr>", {silent = true})
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..ea49ffa
--- /dev/null
+++ b/init.lua
@@ -0,0 +1 @@
+require("user")
diff --git a/lua/user/init.lua b/lua/user/init.lua
new file mode 100644
index 0000000..2b94d59
--- /dev/null
+++ b/lua/user/init.lua
@@ -0,0 +1,31 @@
+require("user.set")
+require("user.map")
+require("user.lazy")
+
+local autocmd = vim.api.nvim_create_autocmd
+
+local function augroup(name)
+ return vim.api.nvim_create_augroup("user_" .. name, { clear = true })
+end
+
+-- [[ Highlight on yank ]]
+autocmd("TextYankPost", {
+ group = augroup("highlight_yank"),
+ callback = function()
+ vim.highlight.on_yank()
+ end,
+})
+
+-- [[ Auto create parent directory if it doesn't exist ]]
+autocmd({ "BufWritePre" }, {
+ group = augroup("auto_create_dir"),
+ callback = function(event)
+ if event.match:match("^%w%w+://") then
+ return
+ end
+ local file = vim.loop.fs_realpath(event.match) or event.match
+ vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
+ end,
+})
+
+vim.cmd("colorscheme nord")
diff --git a/lua/user/lazy.lua b/lua/user/lazy.lua
new file mode 100644
index 0000000..8c4fc3d
--- /dev/null
+++ b/lua/user/lazy.lua
@@ -0,0 +1,103 @@
+-- bootstraping
+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)
+
+-- plugins installation and configuration
+require("lazy").setup({
+ -- lsp setup
+ {
+ -- LSP Support
+ "neovim/nvim-lspconfig",
+ -- lsp download manager
+ "williamboman/mason.nvim",
+ -- automatic lsp setup
+ "williamboman/mason-lspconfig.nvim",
+ -- additional formater support
+ "stevearc/conform.nvim",
+ -- additional linter support
+ "mfussenegger/nvim-lint",
+ -- mason autoinstaller for formatter's and linter's
+ "WhoIsSethDaniel/mason-tool-installer.nvim",
+ -- minimal snippet's support
+ "dcampos/nvim-snippy",
+ -- basic snippet's
+ "honza/vim-snippets",
+ -- cmp for autocompletion
+ "hrsh7th/nvim-cmp",
+ -- cmp nvim-lsp plugin
+ "hrsh7th/cmp-nvim-lsp",
+ -- cmp snippy support
+ "dcampos/cmp-snippy",
+ -- path comletion
+ "hrsh7th/cmp-path",
+ -- kind icons
+ "onsails/lspkind.nvim",
+ },
+ -- Adds git related signs to the gutter, as well as utilities for managing changes
+ "lewis6991/gitsigns.nvim",
+
+ -- better ntrw
+ "tpope/vim-vinegar",
+
+ -- integration with tmux keybinds
+ "christoomey/vim-tmux-navigator",
+
+ -- nord color theme
+ "shaunsingh/nord.nvim",
+
+ -- auto close brackets
+ "m4xshen/autoclose.nvim",
+
+ -- Fuzzy Finder (files, lsp, etc)
+ {
+ "nvim-telescope/telescope.nvim",
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ "nvim-telescope/telescope-ui-select.nvim",
+ {
+ "nvim-telescope/telescope-fzf-native.nvim",
+ build = "make",
+ },
+ },
+ },
+
+ {
+ -- Highlight, edit, and navigate code
+ "nvim-treesitter/nvim-treesitter",
+ build = ":TSUpdate",
+ },
+
+ {
+ -- harpoon your way around code
+ {
+ "ThePrimeagen/harpoon",
+ branch = "harpoon2",
+ requires = { "nvim-lua/plenary.nvim", lazy = true },
+ },
+ },
+
+ -- Minimal neovim modules for a lot of things
+ { "echasnovski/mini.nvim" },
+}, {
+ performance = {
+ rtp = {
+ disabled_plugins = {
+ "gzip",
+ "tarPlugin",
+ "tohtml",
+ "tutor",
+ "zipPlugin",
+ },
+ },
+ },
+})
diff --git a/lua/user/map.lua b/lua/user/map.lua
new file mode 100644
index 0000000..7bcee2f
--- /dev/null
+++ b/lua/user/map.lua
@@ -0,0 +1,78 @@
+local map = vim.keymap.set
+
+-- Leader
+vim.g.mapleader = " "
+vim.g.maplocalleader = ";"
+
+-- Move text easilly
+map("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selected text up" })
+map("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selected text down" })
+
+-- better find next and previous
+map("n", "n", "nzzzv", { desc = "Keep cursor in middle with search" })
+map("n", "N", "Nzzzv", { desc = "Keep cursor in middle with search" })
+
+map("n", "J", "mzJ`z", { desc = "Move up next line with space in between" })
+
+-- greatest remap ever
+map("x", "<leader>p", [["_dP]], { desc = "Paste while keeping the registry" })
+
+-- moving
+vim.keymap.set("i", "<C-a>", "<C-o>I", { noremap = true })
+vim.keymap.set("i", "<C-e>", "<C-o>A", { noremap = true })
+vim.keymap.set("i", "<C-k>", "<C-o>D", { noremap = true })
+
+-- buffers
+vim.keymap.set("n", "gb", "<cmd>buffers<cr>:buffer<Space>", { noremap = true })
+vim.keymap.set("n", "<Leader>q", "<cmd>q!<cr>", { noremap = true })
+vim.keymap.set("n", "<Leader>Q", "<cmd>qa!<cr>", { noremap = true })
+-- close all except focused buffer
+vim.keymap.set("n", "<leader>1", "<cmd>%bd|e#<cr>", { noremap = true })
+-- next tab
+vim.keymap.set("n", "+", "<cmd>tabe .<cr>", { noremap = true })
+
+-- better indenting
+map("v", "<", "<gv")
+map("v", ">", ">gv")
+
+-- allow for use of system clipboard fast
+map({ "n", "v" }, "<leader>y", [["+y]])
+map("n", "<leader>Y", [["+Y]])
+map({ "n", "v" }, "<leader>P", [["+p]])
+
+map({ "n", "v" }, "<leader>d", [["_d]])
+
+
+-- templates
+vim.keymap.set("n", "<LocalLeader>rt", ":-1r " .. vim.fn.stdpath("config") .. "/templates", { noremap = true })
+
+-- hide all
+local s = {hidden_all = 0}
+vim.keymap.set("n", "<C-h>", function ()
+ s.hidden_all = 1 - s.hidden_all
+ local opt = s.hidden_all == 0
+ vim.opt.showmode = opt
+ vim.opt.ruler = opt
+ vim.opt.nu = opt
+ vim.opt.rnu = opt
+ vim.opt.showcmd = opt
+ vim.opt.laststatus = opt and 2 or 0
+ vim.opt.signcolumn = opt and "yes" or "no"
+end, { noremap = true })
+
+-- write
+vim.keymap.set("n", "<Leader>w", "<cmd>write<cr>", { noremap = true })
+vim.keymap.set("n", "<Leader>W", "<cmd>write!<cr>", { noremap = true })
+vim.keymap.set("n", "<Leader>e", "<cmd>edit<cr>", { noremap = true })
+vim.keymap.set("n", "<LocalLeader>s", function ()
+ vim.cmd.source()
+ print("sourced.")
+end, { noremap = true })
+
+-- Lazy
+vim.keymap.set("n", "<Leader>P", "<cmd>Lazy<cr>", { noremap = true })
+
+-- spelling
+vim.keymap.set("n", "<C-s>s", "<cmd>setlocal spell!<cr>", { noremap = true })
+vim.keymap.set("n", "<C-s>g", "z=1<cr><cr>", { noremap = true })
+
diff --git a/lua/user/set.lua b/lua/user/set.lua
new file mode 100644
index 0000000..2767143
--- /dev/null
+++ b/lua/user/set.lua
@@ -0,0 +1,96 @@
+local opt = vim.opt
+
+-- Don't highlight on search
+opt.hlsearch = false
+opt.incsearch = true
+
+-- Enable line numbers by default
+opt.number = true
+opt.relativenumber = true
+
+-- Tab settings
+opt.tabstop = 4
+opt.softtabstop = 4
+opt.shiftwidth = 4
+opt.expandtab = true
+
+-- Enable smart indenting
+opt.smartindent = true
+
+-- Enable break indent
+opt.breakindent = true
+
+-- History settings
+opt.undofile = true
+opt.undodir = os.getenv("HOME") .. "/.local/state/nvim"
+opt.swapfile = true
+opt.swapfile = true
+
+-- Case-insensitive searching UNLESS \C or capital in search
+opt.ignorecase = true
+opt.smartcase = true
+
+-- Keep signcolumn on by default
+opt.signcolumn = "yes"
+
+-- Decrease update time
+opt.updatetime = 50
+opt.timeoutlen = 300
+
+-- Set completeopt to have a better completion experience
+opt.completeopt = "menuone,noselect"
+
+-- Enable true color support
+opt.termguicolors = true
+
+-- Enable scroll off
+opt.scrolloff = 8
+
+-- Don't show mode I'm in, already have a nice status line for that
+opt.showmode = false
+
+-- Better split options
+opt.splitbelow = true
+opt.splitright = true
+
+-- shared clipboard
+opt.clipboard = "unnamed"
+-- do not highlight matched bracket
+opt.showmatch = false
+-- highlight line at cursor
+opt.cursorline = true
+
+-- status line
+-- show ruler
+opt.ruler = true
+-- show command
+opt.showcmd = true
+
+opt.wildmenu = true
+
+opt.mouse = ""
+
+opt.backspace = "indent,eol,start"
+
+opt.laststatus = 2
+opt.history = 200
+opt.encoding = "utf-8"
+opt.fileencoding = "utf-8"
+
+opt.smartindent = true
+opt.scrolloff = 8
+
+opt.spelllang = "en_us,nl"
+opt.formatoptions = "cqrnj"
+
+-- Get the current working directory, replace the $HOME portion of the path with ~,
+-- and extract the last three directories
+local cwd = vim.fn.getcwd():gsub(os.getenv('HOME'), '~')
+local last_dirs = string.match(cwd, "[^/]+/[^/]+/[^/]+/?$")
+if last_dirs then
+ opt.titlestring = last_dirs .. " -> %t"
+else
+ opt.titlestring = cwd .. " -> %t"
+end
+
+opt.title = true
diff --git a/templates/c.make b/templates/c.make
new file mode 100644
index 0000000..2af2129
--- /dev/null
+++ b/templates/c.make
@@ -0,0 +1,4 @@
+FILE =
+
+$(FILE): $(FILE).cpp
+ gcc -Wall -Werror -g $(FILE).cpp -o $(FILE)