From ddf033ee924d13e988ca629bcf9e63da0e711857 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Tue, 20 Apr 2021 14:34:02 +0200 Subject: [PATCH] port nvim config to lua (oooh yeah!) --- nvim/coc-settings.json | 5 +- nvim/init.lua | 4 ++ nvim/init.vim | 106 ----------------------------------------- nvim/lua/maps.lua | 41 ++++++++++++++++ nvim/lua/plugins.lua | 26 ++++++++++ nvim/lua/settings.lua | 39 +++++++++++++++ 6 files changed, 114 insertions(+), 107 deletions(-) create mode 100644 nvim/init.lua delete mode 100644 nvim/init.vim create mode 100644 nvim/lua/maps.lua create mode 100644 nvim/lua/plugins.lua create mode 100644 nvim/lua/settings.lua diff --git a/nvim/coc-settings.json b/nvim/coc-settings.json index c1b585d..c648d2e 100644 --- a/nvim/coc-settings.json +++ b/nvim/coc-settings.json @@ -12,6 +12,9 @@ "filetypes": ["ocaml", "reason"] } }, - "java.home": "/usr/lib/jvm/java-11-graalvm" + "java.home": "/usr/lib/jvm/java-11-graalvm", + "java.format.enabled": true, + "java.format.onType.enabled": true, + "java.format.settings.url": "/home/lordmzte/.config/coc/extensions/node_modules/redhat.java/https:/raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml" } diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..fd1eddc --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,4 @@ +require("settings") +require("maps") +require("plugins") + diff --git a/nvim/init.vim b/nvim/init.vim deleted file mode 100644 index 4493793..0000000 --- a/nvim/init.vim +++ /dev/null @@ -1,106 +0,0 @@ -syntax on -set tabstop=4 -set shiftwidth=4 -set expandtab -command GoToFile cd %:p:h -tnoremap -set number - -call plug#begin(stdpath('data') . '/plugged') - -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'scrooloose/nerdtree' -Plug 'jdonaldson/vaxe', {'branch' : 'neovaxe', 'do' : 'sh install.sh'} -Plug 'SirVer/ultisnips' - let g:UltiSnipsSnippetDirectories=["UltiSnips", "bundle/UltiSnips/UltiSnips"] - -Plug 'Xuyuanp/nerdtree-git-plugin' -Plug 'tiagofumo/vim-nerdtree-syntax-highlight' -Plug 'ryanoasis/vim-devicons' -Plug 'cespare/vim-toml' -Plug '~/go/src/github.com/junegunn/fzf' -Plug 'dracula/vim', { 'as': 'dracula' } -Plug 'cespare/vim-toml' -Plug 'jiangmiao/auto-pairs' -Plug 'tpope/vim-endwise' -Plug 'vimwiki/vimwiki' -Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } } -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'jreybert/vimagit' -Plug 'airblade/vim-gitgutter' -Plug 'dag/vim-fish' -Plug 'uiiaoo/java-syntax.vim' - -call plug#end() - -colorscheme dracula - -let g:airline_powerline_fonts = 1 -let g:neovide_iso_layout = v:true -let NERDTreeShowHidden=1 - -set guifont=Iosevka:h12 -nnoremap fzf :FZF - -" quick cursor movement while holding ctrl -nnoremap 5k -nnoremap 5j - -" quick pasting/yoinking to system register -nnoremap +y "+y -nnoremap +p "+p -nnoremap +d "+d - -nnoremap *y "*y -nnoremap *p "*p -nnoremap *d "*d - -" firemvim config -let g:firenvim_config = { - \ 'localSettings': { - \ '.*twitch\.tv.*': { - \ 'takeover': 'never' - \ } - \ } -\ } - -" Symbol renaming. -nmap cn (coc-rename) - -" Apply AutoFix to problem on the current line. -nmap cf (coc-fix-current) - -" GoTo code navigation. -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -" Use K to show documentation in preview window. -nnoremap K :call show_documentation() - -" Use space o to show symbols -nnoremap o :CocList -I symbols - -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - elseif (coc#rpc#ready()) - call CocActionAsync('doHover') - else - execute '!' . &keywordprg . " " . expand('') - endif -endfunction - -" Highlight the symbol and its references when holding the cursor. -autocmd CursorHold * silent call CocActionAsync('highlight') - -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists('s:std_in') && !exists("g:started_by_firenvim") | NERDTree | endif - -filetype plugin on -set nocompatible -set mouse=a -set termguicolors - diff --git a/nvim/lua/maps.lua b/nvim/lua/maps.lua new file mode 100644 index 0000000..310741f --- /dev/null +++ b/nvim/lua/maps.lua @@ -0,0 +1,41 @@ +local map = vim.api.nvim_set_keymap + +-- Getting stuck in ~~vim~~ terminal +map("t", "", "", { noremap = true }) +map("n", "fzf", ":FZF", { silent = true, noremap = true }) + +-- Quick cursor movement +map("n", "", "5k", { noremap = true }) +map("n", "", "5j", { noremap = true }) + +-- Quick pasting/yoinking to system register +map("n", "+y", "\"+y", { noremap = true }) +map("n", "+p", "\"+p", { noremap = true }) +map("n", "+d", "\"+d", { noremap = true }) + +map("n", "*y", "\"*y", { noremap = true }) +map("n", "*p", "\"*p", { noremap = true }) +map("n", "*d", "\"*d", { noremap = true }) + +-- symbol renaming +map("n", "cn", "(coc-rename)", { silent = true, noremap = true }) +-- apply AutoFix to problem on current line +map("n", "cf", "(coc-fix-current)", { silent = true, noremap = true }) +-- open action dialog +map("n", "ca", ":CocAction", { silent = true, noremap = true }) + +-- GoTo code navigation. +map("n", "gd", "(coc-definition)", { silent = true, noremap = true }) +map("n", "gy", "(coc-type-definition)", { silent = true, noremap = true }) +map("n", "gi", "(coc-implementation)", { silent = true, noremap = true }) +map("n", "gr", "(coc-references)", { silent = true, noremap = true }) + +-- Use K to show documentation in preview window. +map("n", "K", ":call CocActionAsync(\'doHover\')", { silent = true, noremap = true }) + +-- use space o to show symbols +map("n", "o", ":CocList -I symbols", { silent = true, noremap = true }) + +-- format code +map("n", "cr", ":call CocActionAsync(\'format\')", { silent = true, noremap = true }) + diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua new file mode 100644 index 0000000..9ae01a8 --- /dev/null +++ b/nvim/lua/plugins.lua @@ -0,0 +1,26 @@ +vim.cmd [[packadd packer.nvim]] + +return require("packer").startup(function(use) + use "wbthomason/packer.nvim" + + use {"neoclide/coc.nvim", branch = "release"} + use "scrooloose/nerdtree" + use {"jdonaldson/vaxe", branch = "neovaxe", run = "sh install.sh"} + use "SirVer/ultisnips" + use "Xuyuanp/nerdtree-git-plugin" + use "tiagofumo/vim-nerdtree-syntax-highlight" + use "ryanoasis/vim-devicons" + use "cespare/vim-toml" + use "~/go/src/github.com/junegunn/fzf" + use {"dracula/vim", as = "dracula"} + use "jiangmiao/auto-pairs" + use "tpope/vim-endwise" + use "vimwiki/vimwiki" + use {"glacambre/firenvim", run = function() vim.fn["firenvim#install"](0) end} + use 'vim-airline/vim-airline' + use 'vim-airline/vim-airline-themes' + use 'jreybert/vimagit' + use 'airblade/vim-gitgutter' + use 'dag/vim-fish' + use 'uiiaoo/java-syntax.vim' +end) diff --git a/nvim/lua/settings.lua b/nvim/lua/settings.lua new file mode 100644 index 0000000..d51df31 --- /dev/null +++ b/nvim/lua/settings.lua @@ -0,0 +1,39 @@ +local cmd = vim.cmd + +local o = vim.o +local wo = vim.wo +local g = vim.g + +cmd("syntax on") +o.tabstop = 4 +o.shiftwidth = 4 +o.expandtab = true +wo.number = true +o.guifont = "Iosevka:h12" +o.mouse = "a" +o.termguicolors = true + +g.airline_powerline_fonts = 1 +g.neovide_iso_layout = true +g.NERDTreeShowHidden = true + +cmd("colorscheme dracula") + +-- firenvim config +local localSettings = {} +localSettings[".*twitch\\.tv.*"] = { + takeover = "never" +} + +g.firenvim_config = { + localSettings = localSettings +} + +-- Highlight the symbol and its references when holding the cursor. +cmd("autocmd CursorHold * silent call CocActionAsync('highlight')") + +cmd("autocmd StdinReadPre * let s:std_in=1") +cmd("autocmd VimEnter * if argc() == 0 && !exists('s:std_in') && !exists('g:started_by_firenvim') | NERDTree | endif") + +cmd("filetype plugin on") +