chore: migrate vim to lua

This commit is contained in:
Tine 2024-01-31 23:25:49 +01:00
parent a19dff262d
commit 186d5e5cc6
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw
4 changed files with 165 additions and 225 deletions

View file

@ -1,2 +1,2 @@
--italic-text='always' --italic-text='always'
--theme=OneHalfLight --theme=OneHalfDark

161
nvim/init.lua Normal file
View file

@ -0,0 +1,161 @@
-- Plugins
local Plug = vim.fn["plug#"]
vim.call("plug#begin")
-- Dependencies by multiple plugins
Plug("nvim-lua/plenary.nvim")
-- General
Plug("ojroques/nvim-osc52")
-- Look
Plug("rose-pine/neovim", { as = "rose-pine", tag = "v1.*" })
Plug("nvim-lualine/lualine.nvim")
Plug("Yggdroot/indentLine")
Plug("koenverburg/peepsight.nvim")
Plug("norcalli/nvim-colorizer.lua")
Plug("j-hui/fidget.nvim")
-- Git
Plug("lewis6991/gitsigns.nvim")
-- Search/Files
Plug("nvim-lua/plenary.nvim")
Plug("nvim-telescope/telescope.nvim")
Plug("ANGkeith/telescope-terraform-doc.nvim")
Plug("fannheyward/telescope-coc.nvim")
Plug("FeiyouG/commander.nvim")
-- Ignore/Edit files
Plug("vim-scripts/gitignore")
-- Languages
Plug("NoahTheDuke/vim-just")
-- Coding helpers
Plug("zbirenbaum/copilot.lua")
Plug("zbirenbaum/copilot-cmp")
Plug("Exafunction/codeium.nvim")
Plug("petertriho/cmp-git")
Plug("nvim-treesitter/nvim-treesitter", { ["do"] = vim.fn[":TSUpdate"] })
Plug("williamboman/mason.nvim")
Plug("williamboman/mason-lspconfig.nvim")
Plug("neovim/nvim-lspconfig")
Plug("mhartington/formatter.nvim")
Plug("hrsh7th/cmp-nvim-lsp")
Plug("hrsh7th/cmp-cmdline")
Plug("hrsh7th/cmp-buffer")
Plug("hrsh7th/cmp-path")
Plug("hrsh7th/nvim-cmp")
Plug("onsails/lspkind.nvim")
Plug("folke/trouble.nvim")
vim.call("plug#end")
-- TMUX/Clipboard fixes
vim.opt.termguicolors = true
require("osc52").setup({
silent = false,
tmux_passthrough = true,
})
function copy()
if vim.v.event.operator == "y" and vim.v.event.regname == "+" then
require("osc52").copy_register("+")
end
if vim.v.event.operator == "d" and vim.v.event.regname == "+" then
require("osc52").copy_register("+")
end
end
vim.api.nvim_create_autocmd("TextYankPost", { callback = copy })
-- Misc
vim.api.nvim_create_autocmd("FileType", {
pattern = "json",
callback = function()
vim.opt.filetype = jsonc
end,
})
-- VIM Configuration
vim.opt.encoding = "UTF-8"
vim.opt.autoread = true -- will re-read opened file if changed externally
vim.opt.autowrite = true
vim.opt.splitright = true
vim.opt.splitbelow = true
-- Use spaces (2) instead of tabs
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.expandtab = true
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.writebackup = false
vim.opt.incsearch = true -- search as you type
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.mouse = "a"
--vim.opt.spell spelllang=en_us
vim.opt.updatetime = 300
vim.opt.cmdheight = 1
vim.opt.hidden = true
--vim.opt.shortmess = vim.opt.shortmess .. 'c'
-- Custom configurations
require("code_helpers")
require("code_look")
-- Fidget
require("fidget").setup({
notification = {
override_vim_notify = true,
},
})
-- Telescope Configuration
require("telescope").setup({
defaults = {
layout_strategy = "vertical",
},
extensions = {
terraform_doc = {
url_open_command = "xdg-open",
latest_provider_symbol = "",
wincmd = "botright new",
wrap = "nowrap",
},
},
})
require("telescope").load_extension("terraform_doc")
-- Keybindings
-- Using SPACE as <leader> key
vim.keymap.set("n", "<SPACE>", "<Nop>")
vim.g.mapleader = " "
require("keybindings")
-- Visuals
vim.opt.termguicolors = true
vim.opt.showmode = false
vim.opt.number = true
vim.opt.cursorline = true
vim.opt.hlsearch = true -- highlight all results
vim.opt.signcolumn = "number" -- always show git diff column
-- Theme configuration
require("theme")
require("lualine").setup({
options = {
theme = "rose-pine",
section_separators = { "", "" },
component_separators = { "", "" },
icons_enabled = true,
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff" },
lualine_c = { "filename" },
lualine_x = { "diagnostics", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
})

View file

@ -1,192 +0,0 @@
" Run PlugInstall if there are missing plugins
autocmd VimEnter *
\ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | q
\| endif
"""""
"--- Plugins
call plug#begin()
" Dependencies by multiple plugins
Plug 'nvim-lua/plenary.nvim'
" General
Plug 'ojroques/vim-oscyank'
Plug 'tpope/vim-obsession'
Plug 'tmux-plugins/vim-tmux-focus-events'
" Look
Plug 'rose-pine/neovim', {'as': 'rose-pine', 'tag': 'v1.*'}
Plug 'nvim-lualine/lualine.nvim'
Plug 'Yggdroot/indentLine'
Plug 'koenverburg/peepsight.nvim'
Plug 'norcalli/nvim-colorizer.lua'
Plug 'j-hui/fidget.nvim'
" Git
Plug 'lewis6991/gitsigns.nvim'
" Search/Files
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'ANGkeith/telescope-terraform-doc.nvim'
Plug 'fannheyward/telescope-coc.nvim'
Plug 'FeiyouG/commander.nvim'
" Ignore/Edit files
Plug 'vim-scripts/gitignore'
" Languages
Plug 'NoahTheDuke/vim-just'
" Coding helpers
Plug 'zbirenbaum/copilot.lua'
Plug 'zbirenbaum/copilot-cmp'
Plug 'Exafunction/codeium.nvim'
Plug 'petertriho/cmp-git'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'mhartington/formatter.nvim'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/nvim-cmp'
Plug 'onsails/lspkind.nvim'
Plug 'folke/trouble.nvim'
call plug#end()
"""""
"--- TMUX/Clipboard fixes
set t_Co=256
set t_ut=
" Set Vim-specific sequences for RGB colors
" Fixes 'termguicolors' usage in vim+tmux
" :h xterm-true-color
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Enables 24-bit RGB color in the terminal
if has('termguicolors')
if empty($COLORTERM) || $COLORTERM =~# 'truecolor\|24bit'
set termguicolors
endif
endif
" Use system clipboard to get buffers synced between TMUX and VIM
if has('clipboard') && has('vim_starting')
" set clipboard& clipboard+=unnamedplus
set clipboard& clipboard^=unnamed,unnamedplus
endif
if exists('##TextYankPost')
augroup BlinkClipboardIntegration
autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '' | execute 'OSCYankRegister +' | endif
autocmd TextYankPost * if v:event.operator is 'd' && v:event.regname is '' | execute 'OSCYankRegister +' | endif
augroup END
endif
"""""
"--- Misc
augroup JsonToJsonc
autocmd! FileType json set filetype=jsonc
augroup END
au BufRead,BufNewFile *.mdx setfiletype markdown
"""""
"--- VIM Configuration
set encoding=UTF-8
set autoread " will re-read opened file if changed externally
set autowrite
set splitright
set splitbelow
" Use spaces (2) instead of tabs
set autoindent
set smartindent
set expandtab
set tabstop =2
set softtabstop=2
set shiftwidth =2
set noswapfile
set nobackup
set nowritebackup
set incsearch " search as you type
set ignorecase
set smartcase
set mouse=a
"set spell spelllang=en_us
set updatetime=300
set cmdheight=1
set hidden
set shortmess+=c
"""""
" Custom configurations
lua require('code_helpers')
lua require('code_look')
"""""
"--- Fidget
lua <<EOF
require("fidget").setup {
notification = {
override_vim_notify = true,
},
}
EOF
"""""
"--- Telescope Configuration
lua <<EOF
require'telescope'.setup {
defaults = {
layout_strategy = 'vertical',
},
extensions = {
terraform_doc = {
url_open_command = "xdg-open",
latest_provider_symbol = "  ",
wincmd = "botright new",
wrap = "nowrap",
}
}
}
require'telescope'.load_extension('terraform_doc')
EOF
"""""
"- Keybindings
" Using SPACE as <leader> key
nnoremap <SPACE> <Nop>
let mapleader = " "
lua require('keybindings')
"""""
"- Visuals
set termguicolors
set noshowmode
set number
set cursorline
set hlsearch " highlight all results
set signcolumn=number " always show git diff column
""" Theme configuration
lua require('theme')
lua << END
require('lualine').setup({
options = {
theme = 'rose-pine',
section_separators = {'', ''},
component_separators = {'', ''},
icons_enabled = true,
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff'},
lualine_c = {'filename'},
lualine_x = {'diagnostics', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
})
END

View file

@ -1,41 +1,12 @@
-- Colors the code -- Colors the code
require("nvim-treesitter.configs").setup({ require("nvim-treesitter.configs").setup({
ensure_installed = { ensure_installed = "all",
"python", ignore_install = { "yaml" }, -- Issues with libstdc++6 and nix.
"bash",
"dockerfile",
"go",
"graphql",
"hcl",
"terraform",
"javascript",
"json",
"make",
"markdown",
"prisma",
"proto",
"rust",
"typescript",
"vim",
"yaml",
"glsl",
"glimmer",
"jsonc",
"lua",
"blueprint",
},
-- Install languages synchronously (only applied to `ensure_installed`) -- Install languages synchronously (only applied to `ensure_installed`)
sync_install = false, sync_install = false,
highlight = { highlight = {
-- `false` will disable the whole extension
enable = true, enable = true,
-- list of language that will be disabled disable = { "yaml" }, -- Issues with libstdc++6 and nix.
disable = { "" },
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
}, },
indent = { indent = {
-- dont enable this, messes up python indentation -- dont enable this, messes up python indentation