diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1a9f730 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:latest + +USER root + +RUN apt-get update +RUN apt-get install neovim curl git nodejs -y + +RUN useradd -ms /bin/bash myuser + +USER myuser + +RUN sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + +WORKDIR /home/myuser diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..5a78d34 --- /dev/null +++ b/init.lua @@ -0,0 +1,233 @@ +local plug = vim.fn["plug#"] + +vim.call("plug#begin", "~/.vim/plugged") + +vim.cmd.source("~/dotfiles/plugs.vim") + +-- Coc-nvim +plug("neoclide/coc.nvim", {branch = "release"}) + +-- Editor plugs +plug("nvim-treesitter/nvim-treesitter", {["do"] = ":TSUpdate"}) +plug("scrooloose/nerdtree", { on = "NERDTreeToggle" }) +plug("itchyny/lightline.vim") +plug("jreybert/vimagit") +plug("Lokaltog/vim-easymotion") +plug("tpope/vim-surround") +plug("junegunn/fzf", { dir = "~/.fzf", ["do"] = "./install --all --no-update-rc" }) +plug("junegunn/fzf.vim") +plug("tpope/vim-repeat") +plug("jiangmiao/auto-pairs") +plug("vim-test/vim-test") + +-- Elixir & Erlang +plug("elixir-editors/vim-elixir") +plug("mhinz/vim-mix-format") +vim.g.mix_format_on_save = 1 +plug("fishcakez/vim-erlang") + +-- Elm +plug("ElmCast/elm-vim") +vim.g.elm_format_autosave = 1 + +-- Ruby +plug("thoughtbot/vim-rspec") +plug("aklt/plantuml-syntax") + +-- Go +plug("fatih/vim-go") +vim.g.go_fmt_autosave = 1 +vim.g.go_metalinter_autosave = 0 + +-- Docker +plug("ekalinin/Dockerfile.vim") + +-- CSS syntax highlight +plug("othree/csscomplete.vim") +-- Add Support css3 properties +plug("hail2u/vim-css3-syntax") +plug("cakebaker/scss-syntax.vim") +-- highlight hex colors in color +vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { + pattern = "*.scss", + callback = function(_) + vim.opt.filetype = "scss.css" + end +}) +vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { + pattern = "*.sass", + callback = function(_) + vim.opt.filetype = "sass.css" + end +}) +-- scss lint +plug("gcorne/vim-sass-lint") + +------- Javascript +-- Syntax highlighting for .jsx (typescript) +plug("peitalin/vim-jsx-typescript") +-- Typescript - +plug("leafgarland/typescript-vim") +plug("Shougo/vimproc.vim", { + build = { + windows = "tools\\update-dll-mingw", + cygwin = "make -f make_cygwin.mak", + mac = "make -f make_mac.mak", + linux = "make", + unix = "gmake", + }, +}) + +plug("elzr/vim-json") +vim.g.vim_json_syntax_conceal = 0 +-- GraphQL syntax highlighting +-- plug("jparise/vim-graphql") +-- plug("posva/vim-vue") + + +------- Brackets & Parentheses highlighting +-- Valloric/MatchTagAlways -- +vim.keymap.set("n", "%", ":MtaJumpToOtherTag", { remap = false }) +vim.g.mta_filetypes = { + html= 1, + xhtml = 1, + xml = 1, + javascript = 1, + [ "javascript.jsx" ] = 1, + [ "javascript.tsx" ] = 1, + [ "typescript.tsx" ] = 1, + typescript = 1 +} + +-- C-m is synonymous with "enter", so will cause enter key to lag +vim.g.user_emmet_leader_key = "" +vim.g.user_emmet_settings = { javascript = { extends = "jsx" }} + +-- Color themes +plug("morhetz/gruvbox") +plug("jnurmine/Zenburn") +plug("petobens/colorish") +plug("dracula/vim", { as = "dracula" }) +plug("NLKNguyen/papercolor-theme") + +vim.call("plug#end") + +vim.cmd.source("~/dotfiles/vimrc") + +vim.opt.hidden = true -- Allow buffers to become hidden (default) +vim.opt.encoding = "utf-8" -- Use UTF-8 encoding (default) +vim.opt.incsearch = true -- Move while searching (default) +vim.opt.laststatus = 2 -- Always show the status line (default) +vim.opt.report = 2 -- Tell us when anything is changed via :... +vim.opt.scrolloff = 10 -- Keep 10 lines (top/bottom) for scope +vim.opt.showcmd = true -- Show the command being typed (default) +vim.opt.showmatch = true -- Show matching brackets +vim.opt.backspace = { "indent", "eol" , "start" } -- (default) +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true +vim.opt.virtualedit = "block" -- Allow the cursor to go anywhere in visual block mode +vim.opt.relativenumber = true -- Relative line numbers +vim.opt.number = true -- Line numbers [:set number!] to turn off +vim.opt.numberwidth = 5 -- We are good up to 99999 lines +vim.opt.sidescrolloff = 10 -- Keep 5 lines at the size +vim.opt.list = true -- Show whitespace and tabs +vim.opt.listchars = { tab = "¦·", trail = "·" } -- Show tabs and trailing whitespace +vim.opt.clipboard = "unnamed" -- Copy and paste with * +vim.opt.mouse = "a" -- Scrollable term-vim +vim.opt.autoread = true -- (default) +-- TextEdit might fail if hidden is not set. + +-- Some servers have issues with backup files, see #649. +vim.opt.backup = false -- (default) +vim.opt.writebackup = false + +-- Give more space for displaying messages. +vim.opt.cmdheight = 2 + +-- Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable +-- delays and poor user experience. +vim.opt.updatetime = 300 + +-- Don't pass messages to |ins-completion-menu|. +vim.opt.shortmess:append({ c = true }) + +-- Always show the signcolumn, otherwise it would shift the text each time +-- diagnostics appear/become resolved. +vim.opt.signcolumn = "yes" + +-- Allow us to use Ctrl-s and Ctrl-q as keybinds +vim.cmd("silent !stty -ixon") + +-- Restore default behaviour when leaving Vim. +vim.api.nvim_create_autocmd("VimLeave", { + pattern = "*", -- default pattern + command = "silent !stty ixon", +}) + +local function save() + vim.cmd.write() + vim.print("Saved") +end +vim.keymap.set({"n", "v", "o", "i"}, "", save) + +vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, { + pattern = {"*.ts", "*.js"}, + callback = function(_) + vim.print("set filetype to typescript") + vim.opt.filetype = "typescript.tsx" + end +}) +vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, { + pattern = "*.vue", + callback = function(_) + vim.opt.filetype = "vue.typescript" + end +}) + +-- replace tabs with 4 whitespace +-- nmap :%s/\t/ /g + +vim.api.nvim_create_autocmd("FileType", { + pattern = {"typescript.tsx", "javascript.tsx", "javascript", "typescript"}, + callback = function(_) + vim.keymap.set("n", "s", function() + vim.cmd("%s/\t/ /g") + end) + end +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { + "vue.typescript", + "typescript", + -- "*.jsx", + -- "*.tsx", + "json"}, + callback = function(_) + vim.opt_local.commentstring = "// %s" + end +}) + +-- buffers +vim.keymap.set("", "gn", vim.cmd.bnext) +vim.keymap.set("", "gp", vim.cmd.bprev) +vim.keymap.set("n", "b", vim.cmd.buffers) +vim.keymap.set("n", "bd", ":bpspbnbd") + +----------- window navigation +function wincmd(direction) + return function() + vim.cmd.wincmd(direction) + end +end +vim.keymap.set("n", "", wincmd("k"), { silent = true }) +vim.keymap.set("n", "", wincmd("j"), { silent = true }) +vim.keymap.set("n", "", wincmd("h"), { silent = true }) +vim.keymap.set("n", "", wincmd("l"), { silent = true }) + +------------- Color Schemes ---------------- +vim.opt.termguicolors = true +vim.cmd.colorscheme("heraldish") + diff --git a/vimrc b/vimrc index 547bd6c..02977fe 100644 --- a/vimrc +++ b/vimrc @@ -1,149 +1,3 @@ -call plug#begin('~/.vim/plugged') - -" Coc-nvim -Plug 'neoclide/coc.nvim', {'branch': 'release'} - -" Editor plugs -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} -Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } -Plug 'itchyny/lightline.vim' -Plug 'jreybert/vimagit' -Plug 'Lokaltog/vim-easymotion' -Plug 'tpope/vim-surround' -Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all --no-update-rc' } -Plug 'junegunn/fzf.vim' -Plug 'tpope/vim-repeat' -Plug 'jiangmiao/auto-pairs' -Plug 'vim-test/vim-test' - -" Elixir & Erlang -Plug 'elixir-editors/vim-elixir' -Plug 'mhinz/vim-mix-format' -let g:mix_format_on_save = 1 -Plug 'fishcakez/vim-erlang' - -" Elm -Plug 'ElmCast/elm-vim' -let g:elm_format_autosave = 1 - -" Ruby -Plug 'thoughtbot/vim-rspec' -Plug 'aklt/plantuml-syntax' - -" Go -Plug 'fatih/vim-go' -let g:go_fmt_autosave = 1 -let g:go_metalinter_autosave = 0 - -" Color themes -Plug 'morhetz/gruvbox' -Plug 'jnurmine/Zenburn' -Plug 'petobens/colorish' -Plug 'dracula/vim', { 'as': 'dracula' } -Plug 'NLKNguyen/papercolor-theme' - -"" Docker -Plug 'ekalinin/Dockerfile.vim' - -" CSS syntax highlight -Plug 'othree/csscomplete.vim' -" Add Support css3 properties -Plug 'hail2u/vim-css3-syntax' -Plug 'cakebaker/scss-syntax.vim' -" highlight hex colors in color -au BufRead,BufNewFile *.scss set filetype=scss.css -au BufRead,BufNewFile *.sass set filetype=sass.css -" scss lint -Plug 'gcorne/vim-sass-lint' - -""""""" Javascript -" Syntax highlighting for .jsx (typescript) -Plug 'peitalin/vim-jsx-typescript' -"" Typescript " -Plug 'leafgarland/typescript-vim' -Plug 'Shougo/vimproc.vim', { -\ 'build' : { -\ 'windows' : 'tools\\update-dll-mingw', -\ 'cygwin' : 'make -f make_cygwin.mak', -\ 'mac' : 'make -f make_mac.mak', -\ 'linux' : 'make', -\ 'unix' : 'gmake', -\ }, -\ } - -Plug 'elzr/vim-json' -let g:vim_json_syntax_conceal = 0 -" GraphQL syntax highlighting -" Plug 'jparise/vim-graphql' -" Plug 'posva/vim-vue' - -""""""" Brackets & Parentheses highlighting -" Valloric/MatchTagAlways" -nnoremap % :MtaJumpToOtherTag -let g:mta_filetypes = { - \ 'html' : 1, 'xhtml' : 1, 'xml' : 1, - \ 'javascript' : 1, - \ 'javascript.jsx' : 1, - \ 'javascript.tsx' : 1, - \ 'typescript.tsx' : 1, - \ 'typescript' : 1 - \} - -" C-m is synonymous with 'enter', so will cause enter key to lag -let g:user_emmet_leader_key='' -let g:user_emmet_settings = {'javascript': {'extends': 'jsx'}} -call plug#end() - -set hidden -set encoding=utf-8 " Use utf-8 encoding -set incsearch " move while searching -set laststatus=2 " always show the status line -set report=0 " tell us when anything is changed via :... -set scrolloff=10 " Keep 10 lines (top/bottom) for scope -set showcmd " show the command being typed -set showmatch " show matching brackets -set backspace=indent,eol,start -set tabstop=2 -set softtabstop=2 -set shiftwidth=2 -set expandtab " Tabs insert 2 space characters -set virtualedit+=block " Allow the cursor to go anywhere in visual block mode -set relativenumber " Relative line numbers -set number " Line numbers [:set number!] to turn off -set numberwidth=5 " We are good up to 99999 lines -set sidescrolloff=10 " Keep 5 lines at the size -set list " Show whitespace and tabs -set listchars=tab:\¦·,trail:· " show tabs and trailing whitespace -set clipboard=unnamed " copy and paste with * -set mouse=a " Scrollable term-vim -set autoread -" TextEdit might fail if hidden is not set. - -" Some servers have issues with backup files, see #649. -set nobackup -set nowritebackup - -" Give more space for displaying messages. -set cmdheight=2 - -" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable -" delays and poor user experience. -set updatetime=300 - -" Don't pass messages to |ins-completion-menu|. -set shortmess+=c - -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. -set signcolumn=yes - -" Allow us to use Ctrl-s and Ctrl-q as keybinds -silent !stty -ixon -" Restore default behaviour when leaving Vim. -autocmd VimLeave * silent !stty ixon -map :w :echo "Saved" -imap :w :echo "Saved" i - " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. @@ -289,35 +143,12 @@ nnoremap k :CocPrev nnoremap p :CocListResume let mapleader = "\" -" replace tabs with 4 whitespace -" nmap :%s/\t/ /g -autocmd FileType typescript.tsx,javascript.tsx,javascript,typescript nmap s :%s/\t/ /g -autocmd BufNewFile,BufRead *.ts,*.js set filetype=typescript.tsx -autocmd BufNewFile,BufRead *.vue set filetype=vue.typescript -autocmd FileType vue.typescript setlocal commentstring=//\ %s -autocmd FileType typescript setlocal commentstring=//\ %s -autocmd FileType json setlocal commentstring=//\ %s -" autocmd FileType *.jsx,*.tsx setlocal commentstring=//\ %s autocmd FileType json syntax match Comment +\/\/.\+$+ - -"" buffers -" nmap gt :bnext -" nmap tg :bprevious -map gn :bn -map gp :bp -nmap b :Buffers -nmap bd :bpspbnbd " open magit nmap gs :Magit nmap tg :tabprevious -""""""""""" window navigation -nmap :wincmd k -nmap :wincmd j -nmap :wincmd h -nmap :wincmd l - """"""""""" clipboard copy and cut vmap :!pbcopy " yanks and copies to system clipboard @@ -367,8 +198,3 @@ let g:indent_guides_enable_on_vim_startup = 1 let g:indent_guides_tab_guides = 1 " autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=#243e48 ctermbg=237 " autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=#283e48 ctermbg=236 - - -""""""""""""" Color Schemes """""""""""""""" -set termguicolors -colorscheme heraldish