commit c39e13a3535eb220b5a872c03e83f38dd4f8cdc4 Author: Jérémie SALVI Date: Wed Dec 20 18:35:25 2023 +0100 First commit diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..36ed82f --- /dev/null +++ b/init.lua @@ -0,0 +1,108 @@ +vim.g.mapleader = " " +vim.opt.title = true +vim.opt.mouse="" +vim.opt.wrap = true +vim.opt.fileencoding = "utf-8" +vim.opt.clipboard = "unnamedplus" +vim.opt.completeopt = {"menu", "menuone", "preview", "noselect"} +vim.opt.termguicolors = false +vim.opt.laststatus = 3 +--- Search +vim.opt.ignorecase=true +vim.opt.smartcase=true +--- Numbers +vim.opt.number=true +vim.opt.relativenumber=true +--- Tab Options +vim.opt.smartindent = true +vim.opt.smarttab = true +vim.opt.expandtab = true +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.softtabstop = 2 +vim.opt.showtabline = 2 +--- Explorer +vim.g.netrw_banner = 0 +vim.g.netrw_browse_split = 4 +vim.g.netrw_altv = 1 +vim.g.netrw_liststyle = 3 +vim.g.netrw_winsize = 20 +vim.opt.scrolloff = 6 +vim.opt.sidescrolloff = 8 +--- Swapfile +vim.opt.swapfile = false +vim.opt.backup = false + +--- Keymap +-- Resource +vim.keymap.set("n", "r", ":source ~/.config/nvim/init.lua") +-- Explorer +vim.keymap.set("n", "", ":Lexplore") +-- Windows +vim.keymap.set("n", "d", "h") +vim.keymap.set("n", "c", "l") +vim.keymap.set("n", "a", "k") +vim.keymap.set("n", "b", "j") +-- Resize +vim.keymap.set("n", "-", ":vertical resize -3") +vim.keymap.set("n", "+", ":vertical resize +3") +-- Buffer +vim.keymap.set("n", "", ":buffer ") +-- Tabs +vim.keymap.set("n", "tn", ":tabnew") +vim.keymap.set("n", "tc", ":tabclose") +vim.keymap.set("n", "", ":tabnext") +-- Cheatsheet +vim.keymap.set("n", "", ":terminal ~/.config/nvim/nvim_help.shi") +-- No highlight +vim.keymap.set("n", "nl", ":nohl") + +--- Automaticly close brackets +--vim.keymap.set ("i", "'", "''") +--vim.keymap.set ("i", "\"", "\"\"") +--vim.keymap.set ("i", "(", "()") +--vim.keymap.set ("i", "{", "{}") +--vim.keymap.set ("i", "[", "[]") + +--- Statusline +vim.cmd "highlight StatusNormal ctermbg=blue ctermfg=black" +vim.cmd "highlight StatusModified ctermbg=red ctermfg=black" +vim.cmd "highlight StatusGitBranch ctermbg=yellow ctermfg=black" +vim.cmd "highlight StatusGitDiffAdd ctermbg=green ctermfg=black" +vim.cmd "highlight StatusGitdiffRemove ctermbg=red ctermfg=black" + +local function command(cmd) + local handle = io.popen(cmd) + local result = handle:read() + handle:close() + return result or "" +end + +vim.o.statusline = "%#StatusNormal# " + .. "%#StatusGitBranch#" + .. command("git branch 2> /dev/null | sed -e 's/..//'") + .. "%#StatusNormal# " + .. "%#StatusGitDiffAdd#" + .. command("git diff --numstat | awk '{print \"+\"$1}'") + .. "%#StatusNormal# " + .. "%#StatusGitDiffRemove#" + .. command("git diff --numstat | awk '{print \"-\"$2}'") + .. "%#StatusNormal# " + .. ">>" + .. " %F " + .. "%#StatusModified#" + .. "%M" + .. "%#StatusNormal#" + .. " >>" + .. "%=" + .. "<<" + .. " %Y " + .. "<<" + .. " %l,%c " + .. "<<" + .. " %p%% " + + + +require("core") +require("lazy.init") diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..552f196 --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,2 @@ +require("core.keymap") +require("core.options") diff --git a/lua/core/keymap.lua b/lua/core/keymap.lua new file mode 100644 index 0000000..e8bcb59 --- /dev/null +++ b/lua/core/keymap.lua @@ -0,0 +1 @@ +print "toto" diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..db02412 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1 @@ +vim.opt.termguicolors = true diff --git a/lua/lazy/init.lua b/lua/lazy/init.lua new file mode 100644 index 0000000..28ffea3 --- /dev/null +++ b/lua/lazy/init.lua @@ -0,0 +1,24 @@ +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) + +opts = { + install = { + colorsheme = { "onedark" }, + }, + checker = { + enabled = true, + notify = false, + }, +} + +require("lazy").setup("lazy.plugins", opts) diff --git a/lua/lazy/plugins/onedark.lua b/lua/lazy/plugins/onedark.lua new file mode 100644 index 0000000..fd26d13 --- /dev/null +++ b/lua/lazy/plugins/onedark.lua @@ -0,0 +1,10 @@ +function conf() + require('onedark').load() +end + +return { + "navarasu/onedark.nvim", + lazy=false, + priority = 1000, + config = conf +} diff --git a/nvim_help.sh b/nvim_help.sh new file mode 100755 index 0000000..f140b4d --- /dev/null +++ b/nvim_help.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +_CR="\e[170D\e[1B" +_E1="\e[1C" +_E2="\e[2C" +_E_RIGHT="\e[70C" +_BOLD="\e[1m" +_BLACK="\e[38;5;0m" +_RED="\e[38;5;1m" +_BLUE="\e[38;5;4m" +_PURPLE="\e[38;5;5m" +_CYAN="\e[38;5;6m" +_BG_RED="\e[48;5;1m" +_RESET="\e[0m" + +# _title [string:bg_color] [string:message] [bool:right] +_title() { + printf "$_CR$_E1$_BOLD$_BLACK$1" + [[ ! -z $3 ]] && printf "$_E_RIGHT" + for (( i=0; i<(( 10 - ${#2} / 2 )); i++ )) + do + printf " " + done + printf "$2" + for (( i=0; i<(( 10 - ${#2} / 2 )); i++ )) + do + printf " " + done + (( ${#2} % 2 == 0 )) && printf " " + printf "$_RESET$_CR" +} + +# _shortcut [string:modifier] [string:key] [string:message] [bool:right] +_shortcut() { + _MODIFIER=$(sed "s|+|\\\e[38;5;1m+\\\e[38;5;5m|g" <<< $1) + [[ ! -z $4 ]] && printf "$_E_RIGHT" + printf "$_E2" + printf "$_PURPLE$_MODIFIER$_RESET" + [[ ! -z $1 ]] && printf "$_RED+$_RESET" + printf "$_CYAN$2$_RESET" + printf " $3" + printf "$_CR" +} + +_move() { + printf "\e[$1;$2H" +} + +tput civis +clear + +_title "\e[48;5;063m" "Windows" +_shortcut "" "-" "Decrease size" +_shortcut "" "+" "Increase size" +_shortcut "Ctrl" "Arrow" "Navigate" +_shortcut "Ctrl+w" "q" "Quit" +_shortcut "Ctrl+w" "v" "Vertical split" +_shortcut "Ctrl+w" "s" "Horizontal split" +_shortcut "Ctrl+w" "x" "Exchange withnext one" +_shortcut "Ctrl+w" "=" "Reset resizing" + + +_title "\e[48;5;035m" "Buffer" +_shortcut "" "Tab" "Cycle buffer" + +_title "\e[48;5;191m" "tab (:tabxxx)" +_shortcut "Shift" "Tab" "Cycle tables" +_shortcut "Shift" "tn" "New Table" +_shortcut "Leader" "tc" "Close tab" + +_title "\e[48;5;170m" "No Highlight" +_shortcut "Leader" "hl" "Remove search highlight" + +_title "\e[48;5;092m" "Normal mode" +_shortcut "" "w" "Move by word" +_shortcut "" "0" "Move begin of line" +_shortcut "" "$" "Move end of line" +_shortcut "" "gg" "Move begin of buffer" +_shortcut "" "G" "Move end of buffer" + +_title "\e[48;5;204m" "Visual mode" + +_title "\e[48;5;214m" "not finished yet" + +read -n 1 -s