Neovim - switch configuration to lua.

This commit is contained in:
Bartek Stalewski 2023-04-07 16:38:45 +02:00
parent 10b09e931d
commit b23134ce6f
4 changed files with 100 additions and 1 deletions

98
nvim/init.lua Normal file
View file

@ -0,0 +1,98 @@
-- install Lazy
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)
-- define plugins
require("lazy").setup {
{ "tanvirtin/monokai.nvim", config = function() require("monokai").setup() end },
{ "NvChad/nvim-colorizer.lua", config = function() require("colorizer").setup() end },
{ "numToStr/Comment.nvim", config = function() require("Comment").setup() end },
-- "bitc/vim-bad-whitespace",
"lewis6991/gitsigns.nvim",
"nvim-lualine/lualine.nvim",
"nvim-treesitter/nvim-treesitter",
}
-- configure plugins, if needed
require("gitsigns").setup {
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "" },
untracked = { text = "" },
},
}
require("lualine").setup {
options = {
component_separators = '',
icons_enabled = false,
section_separators = '',
theme = "powerline",
},
sections = {
lualine_a = { "mode" },
lualine_b = { { "filename", file_status = true, path = 1 } },
lualine_c = { "branch" },
lualine_x = { "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
}
require("nvim-treesitter.configs").setup {
build = ":TSUpdate",
ensure_installed = { "bash", "python", "terraform", "vim", "yaml" },
highlight = { enable = true },
}
-- modify colorcheme
vim.api.nvim_set_hl(0, "Normal", { bg = NONE })
vim.api.nvim_set_hl(0, "NonText", { bg = NONE })
vim.api.nvim_set_hl(0, "BadWhitespace", { bg = "#770000" })
vim.api.nvim_set_hl(0, "ColorColumn", { bg = "#770000" })
vim.api.nvim_set_hl(0, "DiffChange", { bg = NONE, fg = "#e7c547" })
vim.api.nvim_set_hl(0, "DiffText", { bg = NONE, fg = "#ff8700" })
vim.api.nvim_set_hl(0, "LineNr", { bg = NONE, fg = "#465457" })
vim.api.nvim_set_hl(0, "Visual", { bg = "#005577", fg = "#ffffff" })
vim.api.nvim_set_hl(0, "SpellBad", { bg = "#770000", fg = "#ffffff" })
-- global options
vim.opt.cursorline = true
vim.opt.expandtab = true
vim.opt.gdefault = true
vim.opt.hlsearch = false
vim.opt.ignorecase = true
vim.opt.number = true
vim.opt.shiftround = true
vim.opt.showmode = false
vim.opt.smartcase = true
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.termguicolors = true
vim.opt.writebackup = false
vim.opt.mouse = ""
vim.opt.tabstop = 2
vim.opt.scrolloff = 5
vim.opt.updatetime = 100
vim.opt.shiftwidth = 2
vim.opt.showtabline = 0
vim.opt.softtabstop = 2
-- configure mappings
vim.g.mapleader = " "
vim.api.nvim_set_keymap('n', "<esc><cr>", "<esc>:wq!<cr>", { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', "<leader>c", ":execute 'set colorcolumn=' . (&colorcolumn == '' ? '80,120' : '')<cr>", { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', "<leader>n", ":set nonumber!<cr>:Gitsigns toggle_signs<cr>", { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', "<leader>s", ":set spell!<cr>", { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', "<tab>", "<C-w>w", { noremap = true, silent = true })

View file

@ -1,110 +0,0 @@
call plug#begin('$XDG_DATA_HOME/nvim/plugins')
Plug 'kamykn/skyknight'
Plug 'NvChad/nvim-colorizer.lua'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-commentary'
Plug 'itchyny/lightline.vim'
Plug 'itchyny/vim-gitbranch'
Plug 'airblade/vim-gitgutter'
Plug 'hashivim/vim-terraform'
Plug 'bitc/vim-bad-whitespace'
call plug#end()
lua require 'colorizer'.setup()
set number
set gdefault
set expandtab
set smartcase
set splitbelow
set splitright
set ignorecase
set nohlsearch
set noshowmode
set shiftround
set cursorline
set nowritebackup
set mouse=
set spelllang=en_us,pl
set tabstop=2
set scrolloff=5
set shortmess-=S
set matchpairs+=(:),{:},[:],<:>,':',":"
set updatetime=100
set shiftwidth=2
set showtabline=0
set softtabstop=2
nmap <tab> <C-w>w
nmap <Esc><CR> :wq!<CR>
nmap <C-p> :Files<CR>
nmap <C-a> :Files ~<CR>
map <leader>b <Esc>:set cc=80,120<CR>
map <leader>nb <Esc>:set cc=0<CR>
map <leader>n <Esc>:set nonumber!<CR>:GitGutterSignsToggle<CR>
map <leader>p <Esc>:set paste!<CR>
map <leader>s <Esc>:set spell!<CR>
set bg=dark
set termguicolors
colorscheme skyknight
hi Comment gui=italic
hi Normal guibg=NONE
hi BadWhitespace guibg=#770000
hi ColorColumn guibg=#770000
hi DiffChange guibg=#465457
hi DiffText guifg=#ff8700 guibg=#465457
hi FoldColumn guifg=#465457 guibg=#272822
hi GitGutterChange guifg=#bbbb00 guibg=#272822
hi LineNr guifg=#465457 guibg=#272822
hi NonText guifg=#465457 guibg=NONE
hi SignColumn guifg=#465457 guibg=#272822
hi Visual guibg=#005577
hi SpellBad guibg=#770000
let $FZF_DEFAULT_COMMAND='fd -H -L --ignore-file ~/.local/config/fd'
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['-e', '--layout=reverse', '--preview', 'bat --color=always --style=plain --theme=Monokai\ Extended\ Bright {}']}, <bang>0)
command! -bang -nargs=? -complete=dir Colors
\ call fzf#vim#colors({'options': ['-e', '--layout=reverse', '--preview', '']}, <bang>0)
let g:vim_json_conceal=0
let g:markdown_syntax_conceal=0
let g:gitgutter_sign_modified = '~'
let g:Hexokinase_highlighters = [ 'backgroundfull' ]
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'gitbranch', 'filename' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'filetype' ] ]
\ },
\ 'component_function': {
\ 'readonly': 'LightLineReadonly',
\ 'filename': 'LightLineFilename',
\ 'gitbranch': 'gitbranch#name'
\ }
\ }
function! LightLineReadonly()
return &readonly && &filetype !=# 'help' ? '' : ''
endfunction
function! LightLineFilename()
let root = fnamemodify(get(b:, 'gitbranch_path'), ':h:h')
let path = expand('%:p')
if path[:len(root)-1] ==# root
return path[len(root)+1:]
endif
return expand('%')
endfunction
if filereadable(glob('~/.local/config/init.vim'))
source ~/.local/config/init.vim
endif