diff options
| author | Peter Son Struschka <me@peter-struschka.com> | 2021-06-21 15:16:29 +0800 |
|---|---|---|
| committer | Peter Son Struschka <me@peter-struschka.com> | 2021-06-21 15:16:29 +0800 |
| commit | bf00ce1738a016fcebd546841e702762c8374041 (patch) | |
| tree | 90aa18141adeb6a4ad5349dd7d7d5f0a5df833e5 | |
| parent | 4d63577b487a8bf877401312f22142094e2d4584 (diff) | |
| download | dotfiles-bf00ce1738a016fcebd546841e702762c8374041.tar.gz dotfiles-bf00ce1738a016fcebd546841e702762c8374041.tar.bz2 dotfiles-bf00ce1738a016fcebd546841e702762c8374041.tar.lz dotfiles-bf00ce1738a016fcebd546841e702762c8374041.tar.xz dotfiles-bf00ce1738a016fcebd546841e702762c8374041.tar.zst dotfiles-bf00ce1738a016fcebd546841e702762c8374041.zip | |
nvim: start using lua
| -rw-r--r-- | basics/.config/systemd/user/picom.service | 13 | ||||
| -rw-r--r-- | nvim/.config/nvim/autoload/plug.vim | 25 | ||||
| -rw-r--r-- | nvim/.config/nvim/init.vim | 52 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/pstr/lsp.lua | 12 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/pstr/settings.lua | 40 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/pstr/telescope.lua | 29 | ||||
| -rw-r--r-- | nvim/.config/nvim/plugin/colors.vim | 27 | ||||
| -rw-r--r-- | nvim/.config/nvim/plugin/lsp.vim | 12 | ||||
| -rw-r--r-- | nvim/.config/nvim/plugin/telescope.vim | 8 |
9 files changed, 169 insertions, 49 deletions
diff --git a/basics/.config/systemd/user/picom.service b/basics/.config/systemd/user/picom.service new file mode 100644 index 0000000..805d073 --- /dev/null +++ b/basics/.config/systemd/user/picom.service @@ -0,0 +1,13 @@ +[Unit] +Description=A lightweight compositor for X11 +Documentation=info:picom man:picom(1) https://github.com/yshui/picom + +[Service] +Type=simple +ExecStart=/usr/bin/picom +ExecStop=/bin/kill -s QUIT $MAINPID +ExecReload=/bin/kill -s HUP $MAINPID +Restart=on-failure + +[Install] +WantedBy=default.target diff --git a/nvim/.config/nvim/autoload/plug.vim b/nvim/.config/nvim/autoload/plug.vim index 9c296ac..6a958cb 100644 --- a/nvim/.config/nvim/autoload/plug.vim +++ b/nvim/.config/nvim/autoload/plug.vim @@ -116,6 +116,10 @@ let s:TYPE = { let s:loaded = get(s:, 'loaded', {}) let s:triggers = get(s:, 'triggers', {}) +function! s:is_powershell(shell) + return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$' +endfunction + function! s:isabsolute(dir) abort return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)') endfunction @@ -263,7 +267,7 @@ function! s:define_commands() endif if has('win32') \ && &shellslash - \ && (&shell =~# 'cmd\(\.exe\)\?$' || &shell =~# 'powershell\(\.exe\)\?$') + \ && (&shell =~# 'cmd\(\.exe\)\?$' || s:is_powershell(&shell)) return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.') endif if !has('nvim') @@ -503,7 +507,7 @@ if s:is_win let batchfile = s:plug_tempname().'.bat' call writefile(s:wrap_cmds(a:cmd), batchfile) let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0}) - if &shell =~# 'powershell\(\.exe\)\?$' + if s:is_powershell(&shell) let cmd = '& ' . cmd endif return [batchfile, cmd] @@ -935,7 +939,7 @@ function! s:prepare(...) call s:new_window() endif - nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>bd<cr> + nnoremap <silent> <buffer> q :call <SID>close_pane()<cr> if a:0 == 0 call s:finish_bindings() endif @@ -957,6 +961,15 @@ function! s:prepare(...) endif endfunction +function! s:close_pane() + if b:plug_preview == 1 + pc + let b:plug_preview = -1 + else + bd + endif +endfunction + function! s:assign_name() " Assign buffer name let prefix = '[Plugins]' @@ -975,7 +988,7 @@ function! s:chsh(swap) set shell=sh endif if a:swap - if &shell =~# 'powershell\(\.exe\)\?$' || &shell =~# 'pwsh$' + if s:is_powershell(&shell) let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s' elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$' set shellredir=>%s\ 2>&1 @@ -2216,7 +2229,7 @@ function! plug#shellescape(arg, ...) let script = get(opts, 'script', 1) if shell =~# 'cmd\(\.exe\)\?$' return s:shellesc_cmd(a:arg, script) - elseif shell =~# 'powershell\(\.exe\)\?$' || shell =~# 'pwsh$' + elseif s:is_powershell(shell) return s:shellesc_ps1(a:arg) endif return s:shellesc_sh(a:arg) @@ -2268,7 +2281,7 @@ function! s:system(cmd, ...) return system(a:cmd) endif let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})')) - if &shell =~# 'powershell\(\.exe\)\?$' + if s:is_powershell(&shell) let cmd = '& ' . cmd endif else diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index e417b9d..3e4ca86 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -1,5 +1,9 @@ call plug#begin('~/.local/share/nvim/plugged') +Plug 'nvim-lua/popup.nvim' +Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim' +Plug 'nvim-telescope/telescope-fzy-native.nvim' + Plug 'editorconfig/editorconfig-vim' Plug 'tpope/vim-sensible' @@ -28,8 +32,6 @@ Plug 'mileszs/ack.vim' Plug 'terryma/vim-multiple-cursors' Plug 'dense-analysis/ale' -Plug 'neoclide/coc.nvim', {'branch': 'release'} - Plug 'lyuts/vim-rtags' Plug 'airblade/vim-gitgutter' @@ -44,42 +46,12 @@ Plug 'nvim-lua/completion-nvim' call plug#end() +lua require'pstr.settings' +lua require'pstr.lsp' +lua require'pstr.telescope' " basics -" tabs syntax on -set tabstop=4 softtabstop=4 -set shiftwidth=4 -set expandtab -set smartindent -set number -set relativenumber -set nohlsearch -set hidden -set noerrorbells -set nowrap -set incsearch -set list -set cursorline -set scrolloff=8 - -set colorcolumn=80 -set signcolumn=yes - -set background=dark -"set background=light -let g:gruvbox_contrast_light="soft" -let g:gruvbox_italic=1 -let g:gruvbox_invert_signs=0 -let g:gruvbox_improved_strings=0 -let g:gruvbox_improved_warnings=1 -let g:gruvbox_undercurl=1 -let g:gruvbox_contrast_dark="soft" -colorscheme gruvbox - -" transparent bg -highlight Normal ctermbg=none -highlight Normal guibg=none "esc imap jk <Esc> @@ -97,16 +69,10 @@ elseif executable('ag') let g:ackprg = 'ag --vimgrep' endif -source $HOME/.config/nvim/modules/coc.vim - -set completeopt=menuone,noinsert,noselect -let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy'] -lua require'lspconfig'.tsserver.setup{ on_attach=require'completion'.on_attach } - "leader let mapleader = " " -noremap <silent> <Leader> :WhichKey '<Space>'<CR> -set timeoutlen=500 +"noremap <silent> <Leader> :WhichKey '<Space>'<CR> +"set timeoutlen=500 "keys diff --git a/nvim/.config/nvim/lua/pstr/lsp.lua b/nvim/.config/nvim/lua/pstr/lsp.lua new file mode 100644 index 0000000..736e405 --- /dev/null +++ b/nvim/.config/nvim/lua/pstr/lsp.lua @@ -0,0 +1,12 @@ +local function on_attach() + return require'completion'.on_attach +end + +require'lspconfig'.tsserver.setup{ on_attach=on_attach } +require'lspconfig'.clangd.setup{ + on_attach=on_attach, + root_dir = function() return vim.loop.cwd() end +} +require'lspconfig'.pyls.setup{ on_attach=on_attach } +require'lspconfig'.rust_analyzer.setup{ on_attach=on_attach } + diff --git a/nvim/.config/nvim/lua/pstr/settings.lua b/nvim/.config/nvim/lua/pstr/settings.lua new file mode 100644 index 0000000..04f54bf --- /dev/null +++ b/nvim/.config/nvim/lua/pstr/settings.lua @@ -0,0 +1,40 @@ +local o = vim.o +local opt = vim.opt +local wo = vim.wo +local bo = vim.bo + +opt.exrc = true -- o.exrc = true +opt.guicursor = '' -- o.guicursor = '' + +opt.rnu = true -- wo.relativenumber = true +opt.nu = true -- wo.number = true +opt.tabstop = 4 -- bo.tabstop = 4 +opt.ts = 4 -- bo.softtabstop = 4 +opt.sw = 4 -- bo.shiftwidth = 4 +opt.et = true -- bo.expandtab = true +opt.wrap = false -- wo.wrap = false +opt.scs = true -- o.smartcase = true +opt.ic = false -- o.ignorecase = false +opt.hlsearch = false -- o.hlsearch = false +opt.hidden = true -- o.hidden = true + +opt.eb = false -- o.errorbells = false +opt.is = true -- o.incsearch = true +opt.list = true -- wo.list = true +opt.cul = true -- wo.cursorline = true +opt.so = 12 -- o.scrolloff = 12 +opt.smd = false -- o.showmode = false + +opt.swf = false -- bo.swapfile = false +opt.bk = false -- o.backup = false +opt.udir = "$XDG_CACHE_HOME/nvim/undodir" -- o.undodir="~/.cache/nvim/undodir" +opt.udf = true -- bo.undofile = true + +opt.tgc = true -- o.termguicolors = true +opt.cc = '80' -- wo.colorcolumn = '80' +opt.scl = 'yes' -- wo.signcolumn = 'yes' + +opt.shm:append({ c = true}) -- o.shortmess = o.shortmess .. 'c' +opt.ch = 2 -- o.cmdheight = 2 +opt.ut = 50 -- o.updatetime = 50 + diff --git a/nvim/.config/nvim/lua/pstr/telescope.lua b/nvim/.config/nvim/lua/pstr/telescope.lua new file mode 100644 index 0000000..f0cee29 --- /dev/null +++ b/nvim/.config/nvim/lua/pstr/telescope.lua @@ -0,0 +1,29 @@ +require('telescope').setup { + defaults = { + file_sorter = require'telescope.sorters'.get_fzy_sorter, + color_devicons = true, + + file_previewer = require'telescope.previewers'.vim_buffer_cat.new, + grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, + qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, + }, + extensions = { + fzy_native = { + override_generic_sorter = false, + override_file_sorter = true, + } + } +} + +require'telescope'.load_extension('fzy_native') + +local M = {} +M.search_dotfiles = function() + require'telescope.builtin'.find_files({ + prompt_title = "< dotfiles >", + cwd = "$HOME/.local/share/dotfiles/dotfiles/", + }) +end + +return M + diff --git a/nvim/.config/nvim/plugin/colors.vim b/nvim/.config/nvim/plugin/colors.vim new file mode 100644 index 0000000..3881d79 --- /dev/null +++ b/nvim/.config/nvim/plugin/colors.vim @@ -0,0 +1,27 @@ +let g:pstr_colorscheme = "gruvbox" +fun! SetColors() + colorscheme gruvbox + set background=dark + + let g:gruvbox_contrast_dark = 'hard' + let g:gruvbox_contrast_light = 'hard' + let g:gruvbox_italic=1 + let g:gruvbox_invert_signs=0 + let g:gruvbox_improved_strings=0 + let g:gruvbox_improved_warnings=1 + let g:gruvbox_undercurl=1 + if exists('+termguicolors') + let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" + let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" + endif + let g:gruvbox_invert_selection='0' + + highlight ColorColumn ctermbg=0 guibg=grey + highlight Normal guibg=none + highlight LineNr guifg=#5eacd3 + highlight netrwDir guifg=#5eacd3 + highlight qfFileName guifg=#aed75f +endfun +call SetColors() + +nnoremap <leader>vwm :call SetColors()<CR> diff --git a/nvim/.config/nvim/plugin/lsp.vim b/nvim/.config/nvim/plugin/lsp.vim new file mode 100644 index 0000000..ab11056 --- /dev/null +++ b/nvim/.config/nvim/plugin/lsp.vim @@ -0,0 +1,12 @@ +set completeopt=menuone,noinsert,noselect +let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy'] + +nnoremap <leader>vd :lua vim.lsp.buf.definition()<CR> +nnoremap <leader>vi :lua vim.lsp.buf.implementation()<CR> +nnoremap <leader>vsh :lua vim.lsp.buf.signature_help()<CR> +nnoremap <leader>vrr :lua vim.lsp.buf.references()<CR> +nnoremap <leader>vrn :lua vim.lsp.buf.rename()<CR> +nnoremap <leader>vh :lua vim.lsp.buf.hover()<CR> +nnoremap <leader>vca :lua vim.lsp.buf.code_action()<CR> +nnoremap <leader>vsd :lua vim.lsp.diagnostic.show_line_diagnostics(); vim.lsp.util.show_line_diagnostics()<CR> +nnoremap <leader>vn :lua vim.lsp.diagnostic.goto_next()<CR> diff --git a/nvim/.config/nvim/plugin/telescope.vim b/nvim/.config/nvim/plugin/telescope.vim new file mode 100644 index 0000000..51cdeaa --- /dev/null +++ b/nvim/.config/nvim/plugin/telescope.vim @@ -0,0 +1,8 @@ +nnoremap <leader>ps :lua require'telescope.builtin'.grep_string({ search = vim.fn.input("Grep For > ")})<CR> +nnoremap <C-p> :lua require'telescope.builtin'.git_files()<CR> +nnoremap <leader>pf :lua require'telescope.builtin'.find_files()<CR> + +nnoremap <leader>pw :lua require'telescope.builtin'.grep_string { search = vim.fn.expand("<cword>") }<CR> +nnoremap <leader>pb :lua require'telescope.builtin'.buffers()<CR> +nnoremap <leader>vh :lua require'telescope.builtin'.help_tags()<CR> +nnoremap <leader>vrc :lua require'pstr.telescope').search_dotfiles()<CR> |
