feat(vim): Migration configuration to Lua

Every configuration file related to Neovim has been moved to Lua.
This comes with a variety of updatly around theming and implementation for better compatiblity accross the environment.
This commit is contained in:
Tanguy Herbron 2023-04-07 18:24:48 +02:00
parent d29aff94c2
commit f02cdb1f1e
4 changed files with 209 additions and 5 deletions

View File

@ -1,2 +1,157 @@
vim.cmd("source ~/.config/nvim/legacy.vim")
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",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{ "Shatur/neovim-ayu", lazy = false, enabled = true },
"junegunn/fzf.vim",
"yggdroot/indentline",
"yuezk/vim-js",
{ "neoclide/coc.nvim", branch = "release" },
{
"nvim-lualine/lualine.nvim",
dependencies = {
"nvim-tree/nvim-web-devicons"
}
},
{
"nvim-telescope/telescope.nvim",
branch = "0.1.x",
dependencies = {
"nvim-lua/plenary.nvim",
"jremmen/vim-ripgrep",
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
"nvim-tree/nvim-web-devicons"
}
},
"tpope/vim-fugitive",
{ "rrethy/vim-hexokinase", build = "make hexokinase" },
"mbbill/undotree",
"skanehira/docker-compose.vim",
"chr4/nginx.vim",
"machakann/vim-highlightedyank",
"godlygeek/tabular",
"preservim/vim-markdown",
"tpope/vim-obsession",
})
--- THEMING ---
require('ayu').setup({
mirage = true,
overrides = function()
if vim.o.background == "dark" then
return {
Normal = {bg = '#0f1419', fg = '#cbccc6'},
Comment = { fg = "#5c6773" }
}
end
end
})
require('ayu').colorscheme()
--- Change default behaviour ---
-- Disable integrated providers
vim.g.loaded_ruby_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_node_provider = 0
-- Disable error bell
vim.opt.errorbells = false
--- Tab configuration ---
-- Show tabs at 4 spaces
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
-- When indenting with '>', use 4 spaces
vim.opt.shiftwidth = 4
-- Insert 4 spaces instead of tab
vim.opt.expandtab = true
--- Line formatting ---
vim.opt.nu = true
vim.opt.wrap = false
--- Search configuration ---
vim.opt.smartcase = true
vim.opt.ignorecase = true
--- Window configuration ---
vim.opt.splitright = true
vim.opt.splitbelow = true
-- Remove duplicate -- INSERT --
vim.opt.showmode = false
--- Operation configuration ---
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = "~/.config/nvim/undodir"
vim.opt.undofile = true
--- Folding behaviour configuration ---
vim.opt.foldmethod = "indent"
vim.opt.foldnestmax = 10
vim.opt.foldenable = false
vim.opt.foldlevel = 99
vim.opt.signcolumn = "no"
--- Miscellaneous ---
-- rg smart root finder and adds git ignore loading for faster execution
if vim.fn.executable("rg") == 1 then
vim.g.rg_derive_root = true
end
-- Disable mouse
vim.opt.mouse = nil
-- Source CoC configuration
vim.cmd("source ~/.config/nvim/coc.vim")
-- IndentLine configuration
vim.g.indentLine_enabled = 1
vim.g.indentLine_char_list = {'|', '¦', '', ''}
vim.g.indentLine_setColors = 1
vim.g.indentLine_color_gui = "#5C6370"
vim.g.indentLine_showFirstIndentLevel = 1
-- Advertise 256 colors capability (for tmux)
vim.t_Co = 256
-- Undocumented ???
--vim.&t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
--vim.&t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
--- Lualine ---
-- Setup
require("lualine").setup({
options = {
theme = "ayu_dark",
section_separators = { left = '', right = '' },
component_separators = { left = '', right = '' },
globalstatus = false,
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {},
lualine_z = {'location'}
},
})
require("keybindings")
-- vim.cmd("source ~/.config/nvim/legacy.vim")

View File

@ -1,6 +1,6 @@
call plug#begin('~/.config/nvim/plugged')
" Ayu color scheme
Plug 'TanguyHerbron/ayu-vim'
Plug 'https://git.halia.dev/therbron/ayu-vim'
Plug 'junegunn/fzf.vim'
@ -64,7 +64,7 @@ Plug 'tpope/vim-obsession'
" Plug 'ekalinin/Dockerfile.vim'
" Vim integration in tmux
Plug 'vimpostor/vim-tpipeline'
"Plug 'vimpostor/vim-tpipeline'
call plug#end()
" Disable integrated providers

View File

@ -0,0 +1,49 @@
local function map(mode, combo, mapping, opts)
local options = {noremap = true}
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.api.nvim_set_keymap(mode, combo, mapping, options)
end
vim.g.mapleader = ' '
-- Navigate through panes using lead key and vim direction
map('', '<leader>h', ':wincmd h<CR>')
map('', '<leader>j', ':wincmd j<CR>')
map('', '<leader>k', ':wincmd k<CR>')
map('', '<leader>l', ':wincmd l<CR>')
-- Move to tab using lead key plus number
map('', '<leader>1', '1gt')
map('', '<leader>2', '2gt')
map('', '<leader>3', '3gt')
map('', '<leader>4', '4gt')
map('', '<leader>5', '5gt')
map('', '<leader>6', '6gt')
map('', '<leader>7', '7gt')
map('', '<leader>8', '8gt')
map('', '<leader>9', '9gt')
map('', '<leader>0', '10gt')
-- Open undotree panel
map('', '<leader>u', ':UndotreeToggle<CR>')
-- Open lazy.nvim
map('', '<leader>p', ':Lazy home<CR>')
--- Telescope ---
-- List project files
vim.keymap.set('', '<C-p>', function() require("telescope-config").project_files() end)
-- Grep through files in project
vim.keymap.set('', '<C-f>', ":Telescope live_grep<CR>")
--- Miscellaneous
-- Toggle line wrap
vim.keymap.set('', '<leader>w', function()
vim.cmd("set wrap! linebreak! nolist!")
end)
-- Format markdown tables
map('', '<leader>t', ":TableFormat")

View File

@ -4,9 +4,9 @@ M.project_files = function()
local opts = {}
vim.fn.system('git rev-parse is-inside-work-tree')
if vim.v.shell_error == 0 then
require"telescope.builtin".git_files({show_untracked=true})
require("telescope.builtin").git_files({show_untracked=true})
else
require"telescope.builtin".find_files(opts)
require("telescope.builtin").find_files(opts)
end
end