From 24a70665461f3f60cf1682b3b03caf2f4f283169 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 4 May 2021 23:08:47 +0200 Subject: [PATCH] add nvim config --- general/.config/nvim/init.lua | 25 ++++++ general/.config/nvim/lua/keys.lua | 17 ++++ general/.config/nvim/lua/plugin-settings.lua | 1 + general/.config/nvim/lua/plugins.lua | 35 ++++++++ .../nvim/lua/plugins/vim-which-key.lua | 2 + general/.config/nvim/lua/settings.lua | 19 ++++ .../.config/nvim/plugin/packer_compiled.vim | 88 +++++++++++++++++++ 7 files changed, 187 insertions(+) create mode 100644 general/.config/nvim/init.lua create mode 100644 general/.config/nvim/lua/keys.lua create mode 100644 general/.config/nvim/lua/plugin-settings.lua create mode 100644 general/.config/nvim/lua/plugins.lua create mode 100644 general/.config/nvim/lua/plugins/vim-which-key.lua create mode 100644 general/.config/nvim/lua/settings.lua create mode 100644 general/.config/nvim/plugin/packer_compiled.vim diff --git a/general/.config/nvim/init.lua b/general/.config/nvim/init.lua new file mode 100644 index 0000000..d90df2d --- /dev/null +++ b/general/.config/nvim/init.lua @@ -0,0 +1,25 @@ +-- Map leader to space +vim.g.mapleader = ' ' + +local fn = vim.fn +local execute = vim.api.nvim_command + +require('settings') +require('plugins') +require('keys') + +vim.cmd 'colorscheme monokai' + +require('plugin-settings') + +-- Setup Lua language server using submodule +-- require('lsp_lua') + +-- Another option is to groups configuration in one folder +-- require('config') + +-- OR you can invoke them individually here +--require('config.colorscheme') -- color scheme +--require('config.completion') -- completion +--require('config.fugitive') -- fugitive + diff --git a/general/.config/nvim/lua/keys.lua b/general/.config/nvim/lua/keys.lua new file mode 100644 index 0000000..84fb76c --- /dev/null +++ b/general/.config/nvim/lua/keys.lua @@ -0,0 +1,17 @@ +-- " Quickly insert an empty new line without entering insert mode + +vim.api.nvim_set_keymap('n', '', 'h', {silent = true}) +vim.api.nvim_set_keymap('n', '', 'j', {silent = true}) +vim.api.nvim_set_keymap('n', '', 'k', {silent = true}) +vim.api.nvim_set_keymap('n', '', 'l', {silent = true}) + +vim.cmd([[ + nnoremap :m .+1== + nnoremap :m .-2== + inoremap :m .+1==gi + inoremap :m .-2==gi + vnoremap :m '>+1gv=gv + vnoremap :m '<-2gv=gv +]]) + +vim.cmd([[let mapleader = " "]]) diff --git a/general/.config/nvim/lua/plugin-settings.lua b/general/.config/nvim/lua/plugin-settings.lua new file mode 100644 index 0000000..d302a05 --- /dev/null +++ b/general/.config/nvim/lua/plugin-settings.lua @@ -0,0 +1 @@ +require('plugins.vim-which-key') diff --git a/general/.config/nvim/lua/plugins.lua b/general/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..4c0193e --- /dev/null +++ b/general/.config/nvim/lua/plugins.lua @@ -0,0 +1,35 @@ +-- vim.cmd [[packadd packer.nvim]] +local execute = vim.api.nvim_command +local fn = vim.fn + +local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' + +if fn.empty(fn.glob(install_path)) > 0 then + execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) + execute 'packadd packer.nvim' +end + +vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are changes in plugins.lua + +-- require('packer').init({display = {non_interactive = true}}) +require('packer').init({display = {auto_clean = false}}) + +return require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + + use 'crusoexia/vim-monokai' + + use 'airblade/vim-gitgutter' + + use 'junegunn/fzf.vim' + use 'tpope/vim-commentary' + + use 'tmux-plugins/vim-tmux' + use 'christoomey/vim-tmux-navigator' + use 'junegunn/goyo.vim' + use 'junegunn/limelight.vim' + use 'liuchengxu/vim-which-key' + + use 'sheerun/vim-polyglot' + use 'numirias/semshi' +end) diff --git a/general/.config/nvim/lua/plugins/vim-which-key.lua b/general/.config/nvim/lua/plugins/vim-which-key.lua new file mode 100644 index 0000000..82bbe96 --- /dev/null +++ b/general/.config/nvim/lua/plugins/vim-which-key.lua @@ -0,0 +1,2 @@ +-- vim.cmd([[nnoremap :WhichKey '']]) +vim.api.nvim_set_keymap('n', '', ':WhichKey ', { noremap = true, silent = true }) diff --git a/general/.config/nvim/lua/settings.lua b/general/.config/nvim/lua/settings.lua new file mode 100644 index 0000000..e1692aa --- /dev/null +++ b/general/.config/nvim/lua/settings.lua @@ -0,0 +1,19 @@ + +vim.wo.relativenumber = true +vim.cmd 'set nu rnu' -- Make current linenumber absolute + +vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else +vim.wo.scrolloff = 5 -- Start scrolling when n lines from edge + +vim.api.nvim_set_option('smarttab', true) +vim.api.nvim_set_option('cindent', true) +vim.api.nvim_set_option('expandtab', true) +vim.api.nvim_set_option('breakindent', true) -- Wrapped lines gets indented +vim.api.nvim_set_option('tabstop', 2) +vim.api.nvim_set_option('shiftwidth', 2) + +vim.cmd 'set formatoptions-=cro' -- No continued comment on + +vim.api.nvim_set_option('termguicolors', true) + +vim.wo.conceallevel = 2 diff --git a/general/.config/nvim/plugin/packer_compiled.vim b/general/.config/nvim/plugin/packer_compiled.vim new file mode 100644 index 0000000..a721609 --- /dev/null +++ b/general/.config/nvim/plugin/packer_compiled.vim @@ -0,0 +1,88 @@ +" Automatically generated packer.nvim plugin loader code + +if !has('nvim-0.5') + echohl WarningMsg + echom "Invalid Neovim version for packer.nvim!" + echohl None + finish +endif + +packadd packer.nvim + +try + +lua << END +local package_path_str = "/home/h7x4/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/h7x4/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/h7x4/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/h7x4/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/home/h7x4/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s)) + if not success then + print('Error running ' .. component .. ' for ' .. name) + error(result) + end + return result +end + +_G.packer_plugins = { + ["fzf.vim"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/fzf.vim" + }, + ["goyo.vim"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/goyo.vim" + }, + ["limelight.vim"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/limelight.vim" + }, + ["packer.nvim"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/packer.nvim" + }, + semshi = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/semshi" + }, + ["vim-commentary"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/vim-commentary" + }, + ["vim-gitgutter"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/vim-gitgutter" + }, + ["vim-monokai"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/vim-monokai" + }, + ["vim-polyglot"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/vim-polyglot" + }, + ["vim-tmux"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/vim-tmux" + }, + ["vim-tmux-navigator"] = { + loaded = true, + path = "/home/h7x4/.local/share/nvim/site/pack/packer/start/vim-tmux-navigator" + } +} + +END + +catch + echohl ErrorMsg + echom "Error in packer_compiled: " .. v:exception + echom "Please check your config for correctness" + echohl None +endtry