From b9fe669dd878aa4e3659da0216da90396d11fe0e Mon Sep 17 00:00:00 2001 From: Sergey Besedin Date: Thu, 27 Jan 2022 15:21:21 +0400 Subject: [PATCH] Update --- cargo/env | 12 +- config/i3/config | 39 +++-- config/nvim/init.vim | 342 +++++++++++++++++++++------------------ config/redshift.conf | 4 +- config/youtube-dl/config | 6 + profile | 4 + xinitrc | 6 +- 7 files changed, 241 insertions(+), 172 deletions(-) create mode 100644 config/youtube-dl/config diff --git a/cargo/env b/cargo/env index a3603cc..4560da0 100644 --- a/cargo/env +++ b/cargo/env @@ -1 +1,11 @@ -export PATH="$HOME/.cargo/bin:$PATH" +#!/bin/sh +# rustup shell setup +# affix colons on either side of $PATH to simplify matching +case ":${PATH}:" in + *:"$HOME/.cargo/bin":*) + ;; + *) + # Prepending path in case a system-installed rustc needs to be overridden + export PATH="$HOME/.cargo/bin:$PATH" + ;; +esac diff --git a/config/i3/config b/config/i3/config index 8538edc..a08aadb 100644 --- a/config/i3/config +++ b/config/i3/config @@ -39,10 +39,8 @@ workspace_auto_back_and_forth no workspace_layout default for_window [class="(?i)firefox"] move container to workspace $ws1 -for_window [class="(?i)thunderbird"] move container to workspace $ws1 for_window [class="(?i)telegram"] move container to workspace $ws2 -for_window [class="(?i)discord"] move container to workspace $ws2 -for_window [class="mpv"] floating enable +for_window [class="mpv"] floating enable border none for_window [class="(?i)zooout"] floating enable for_window [class="(?i)netsurf"] floating enable @@ -79,6 +77,7 @@ bindsym $mod+F2 exec "dmenu_run" bindsym $mod+F4 exec "x edit_project" bindsym $mod+v exec "passmenu" +bindsym $mod+Shift+v exec "passotpmenu" # change focus # QWERTY @@ -125,6 +124,11 @@ bindsym $mod+Shift+w layout toggle split # toggle tiling / floating bindsym $mod+Shift+space floating toggle bindsym $mod+Shift+0 sticky toggle +# Make the currently focused window a scratchpad +bindsym $mod+Shift+minus move scratchpad + +# Show the first scratchpad window +bindsym $mod+space scratchpad show # change focus between tiling / floating windows bindsym $mod+Tab focus mode_toggle @@ -158,6 +162,9 @@ bindsym $mod+7 workspace $ws7 bindsym $mod+8 workspace $ws8 bindsym $mod+9 workspace $ws9 +workspace $ws1 output primary +workspace $ws6 output LVDS1 + # move focused container to workspace bindsym $mod+Shift+1 move container to workspace $ws1 bindsym $mod+Shift+2 move container to workspace $ws2 @@ -201,17 +208,31 @@ mode "resize" { } bindsym $mod+r mode "resize" -# -# Make the currently focused window a scratchpad -bindsym $mod+Shift+minus move scratchpad -# Show the first scratchpad window -bindsym $mod+space scratchpad show +# disable system tray +bar { + tray_output none + output nonprimary + font pango:Iosevka Term, FontAwesome Bold 12px + colors { + background #000000 + statusline #d5c4a1 + separator #666666 + + focused_workspace #B8BB26 #B8BB26 #3c3836 + active_workspace #5f676a #5f676a #fbf1c7 + inactive_workspace #5f676a #5f676a #fbf1c7 + urgent_workspace #fb4934 #fb4934 #fbf1c7 + binding_mode #fb4934 #fb4934 #1d2021 + } +} # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { # strip_workspace_numbers yes + output primary + tray_output primary status_command i3status-rs-with-env ~/.config/i3status-rs/config.toml font pango:Iosevka Term, FontAwesome Bold 12px colors { @@ -242,7 +263,7 @@ bindsym XF86AudioMute exec --no-startup-id amixer -c 0 set Master toggle # bindsym XF86AudioStop exec --no-startup-id mpc stop # bindsym XF86AudioNext exec --no-startup-id mpc next -bindsym $mod+Shift+o exec "~/scripts/xrandr_switcher.sh" +bindsym $mod+Shift+o exec "display_switch" bindsym $mod+minus exec "dunstctl close-all" bindsym $mod+equal exec "dunstctl history-pop" diff --git a/config/nvim/init.vim b/config/nvim/init.vim index 50de171..d5fa1c8 100644 --- a/config/nvim/init.vim +++ b/config/nvim/init.vim @@ -1,8 +1,6 @@ set nocompatible filetype off -source /usr/share/nvim/runtime/plugin/fzf.vim - call plug#begin('$HOME/.config/nvim/bundle') Plug 'tpope/vim-sensible' @@ -13,21 +11,16 @@ Plug 'chriskempson/base16-vim' Plug 'terryma/vim-multiple-cursors' Plug 'Lokaltog/vim-easymotion' -Plug 'rust-lang/rust.vim' -" Plug 'racer-rust/vim-racer' +Plug 'simrat39/rust-tools.nvim' Plug 'vim-ruby/vim-ruby' Plug 'tpope/vim-rails' Plug 'tpope/vim-rake' Plug 'tpope/vim-bundler' Plug 'tpope/vim-markdown' Plug 'calviken/vim-gdscript3' -" Plug 'tpope/vim-projectionist' -" Plug 'tpope/vim-haml' Plug 'ledger/vim-ledger' Plug 'slim-template/vim-slim' Plug 'fatih/vim-go' -" Plug 'wavded/vim-stylus' -" Plug 'digitaltoad/vim-jade' Plug 'Glench/Vim-Jinja2-Syntax' Plug 'HerringtonDarkholme/yats.vim' Plug 'm-pilia/vim-ccls' @@ -53,7 +46,7 @@ Plug 'L3MON4D3/LuaSnip' " Appearance Plug 'itchyny/lightline.vim' Plug 'shinchu/lightline-gruvbox.vim' -Plug 'spywhere/lightline-lsp' +Plug 'bsedin/lightline-lsp' Plug 'editorconfig/editorconfig-vim' Plug 'tpope/vim-surround' @@ -61,8 +54,6 @@ Plug 'tpope/vim-unimpaired' Plug 'tpope/vim-endwise' Plug 'rstacruz/vim-closer' -Plug 'junegunn/fzf.vim' - Plug 'godlygeek/tabular' " LSP @@ -71,7 +62,7 @@ Plug 'hrsh7th/cmp-nvim-lsp' Plug 'folke/lsp-colors.nvim' Plug 'hrsh7th/cmp-buffer' -Plug 'hrsh7th/cmp-path' +" Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/nvim-cmp' @@ -90,6 +81,12 @@ Plug 'powerman/vim-plugin-AnsiEsc' Plug 'vimwiki/vimwiki' Plug 'tbabej/taskwiki' +Plug 'McAuleyPenney/tidy.nvim' " Remove whitespaces +Plug 'Chiel92/vim-autoformat' + +Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' + call plug#end() " Colorscheme @@ -117,9 +114,24 @@ let g:neosnippet#enable_snipmate_compatibility = 1 " Tell Neosnippet about the other snippets let g:neosnippet#snippets_directory='$HOME/.config/nvim/bundle/vim-snippets/snippets' -" nvim-lspconfig lua << EOF + +-- telescope + +require('telescope').setup{ + pickers = { + find_files = { + theme = "dropdown", + }, + live_grep = { + theme = "dropdown", + } + }, +} + +-- nvim-lspconfig + local nvim_lsp = require('lspconfig') -- Use an on_attach function to only map the following keys @@ -147,12 +159,20 @@ local on_attach = function(client, bufnr) buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap('n', 'e', 'lua vim.diagnostic.get()', opts) + buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) + -- buf_set_keymap('n', 'gh', 'lua require(\'lspsaga.provider\').lsp_finder()', opts) + -- buf_set_keymap('n', 'ca', 'lua require(\'lspsaga.codeaction\').code_action()', opts) + -- buf_set_keymap('v', 'ca', ':lua require(\'lspsaga.codeaction\').range_code_action()', opts) + -- buf_set_keymap('n', 'K', 'lua require(\'lspsaga.hover\').render_hover_doc()', opts) + -- buf_set_keymap('n', 'rn', 'lua require(\'lspsaga.rename\').rename()', opts) + -- buf_set_keymap('n', 'gs', 'lua require(\'lspsaga.signaturehelp\').signature_help()', opts) + -- buf_set_keymap('n', 'gd', 'lua require(\'lspsaga.provider\').preview_definition()', opts) + -- buf_set_keymap('n', 'gd', 'lua require(\'lspsaga.provider\').preview_definition()', opts) end -- Use a loop to conveniently call 'setup' on multiple servers and @@ -191,102 +211,145 @@ nvim_lsp.elixirls.setup{ capabilities = capabilities } -EOF - -set completeopt=menu,menuone,noselect - -lua <'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - - [''] = - cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true - }), - - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { 'i', 's' }), - - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, -- For luasnip users. - }, { - { name = 'buffer' }, - }) - }) - - -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } +nvim_lsp.rust_analyzer.setup({ + cmd = { "rust-analyzer" }, + on_attach = on_attach, + capabilities = capabilities, + settings = { + ["rust-analyzer"] = { + assist = { + importGranularity = "module", + importPrefix = "by_self", + }, + cargo = { + loadOutDirsFromCheck = true + }, + procMacro = { + enable = true + }, + } } - }) +}) - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) +require('rust-tools').setup({ + tools = { -- rust-tools options + autoSetHints = true, + hover_with_actions = true, + inlay_hints = { + -- show_parameter_hints = false, + -- parameter_hints_prefix = "", + -- other_hints_prefix = "", + }, + }, + + -- all the opts to send to nvim-lspconfig + -- these override the defaults set by rust-tools.nvim + -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer + server = { + -- on_attach is a callback called when the language server attachs to the buffer + on_attach = on_attach, + settings = { + -- to enable rust-analyzer settings visit: + -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc + ["rust-analyzer"] = { + -- enable clippy on save + checkOnSave = { + allTargets = false, + command = "clippy" + }, + } + } + }, +}) + +-- Setup nvim-cmp. +local cmp = require('cmp') +local luasnip = require('luasnip') +local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +cmp.setup({ + experimental = { + ghost_text = { hl_group = 'Comment' } + }, + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + luasnip.lsp_expand(args.body) -- For `luasnip` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + -- require'snippy'.expand_snippet(args.body) -- For `snippy` users. + end, + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + + [''] = + cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true + }), + + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 's' }), + + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, }) +}) + +-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) EOF " EditorConfig let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] -" FZF ripgrep -nnoremap g :Rg - " NerdTREE silent! nmap :NERDTreeToggle silent! map :NERDTreeFind @@ -360,59 +423,6 @@ highlight GitGutterChangeDeleteLineNr ctermfg=16 ctermbg=18 guifg=#d3869b guibg= highlight link GitGutterAddLineNr GitGutterAddLine highlight link GitGutterDeleteLineNr GitGutterDeleteLine -" fzf -let $FZF_DEFAULT_COMMAND="fd --type file --full-path -c never -H" - -silent! nmap :Files - -" An action can be a reference to a function that processes selected lines -function! s:build_quickfix_list(lines) - call setqflist(map(copy(a:lines), '{ "filename": v:val }')) - copen - cc -endfunction - -" This is the default extra key bindings -let g:fzf_action = { - \ 'ctrl-q': function('s:build_quickfix_list'), - \ 'ctrl-t': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit', - \ 'ctrl-o': 'edit' } - -let g:fzf_preview_window = 'right:60%' - -" let g:fzf_layout = { 'window': { 'width': 0.4, 'height': 0.25 } } -" let g:fzf_preview_window = '' -let g:fzf_buffers_jump = 1 - -autocmd! FileType fzf set laststatus=0 noshowmode noruler - \| autocmd BufLeave set laststatus=2 showmode ruler - -command! -bang -nargs=* Rg - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(), 1, - \ fzf#vim#with_preview(), 0) - -command! -bang -nargs=? -complete=dir Files - \ call fzf#vim#files(, fzf#vim#with_preview(), 0) - -" Customize fzf colors to match your color scheme -let g:fzf_colors = -\ { 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'hl': ['fg', 'Comment'], - \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], - \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], - \ 'hl+': ['fg', 'Statement'], - \ 'info': ['fg', 'PreProc'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'Conditional'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'] } - " Replace current word with yanked or deleted text " nnoremap S "_diwP @@ -442,6 +452,11 @@ let g:tagbar_type_ruby = { \ ] \} +" vim-autoformat +let g:autoformat_autoindent = 1 +let g:autoformat_retab = 1 +let g:autoformat_remove_trailing_spaces = 1 + " Vimwiki let g:vimwiki_list = [{'path': '~/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}] @@ -495,6 +510,12 @@ set noeol " Don’t add empty newlines at the end of file autocmd InsertEnter * set cursorline " Show cursor line in insert mode autocmd InsertLeave * set nocursorline " Hide cursor line in insert mode +" Set updatetime for CursorHold +" 300ms of no cursor movement to trigger CursorHold +set updatetime=1000 +" Show diagnostic popup on cursor hold +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) + " Visual set showmatch " Show matching brackets. set mat=5 " Bracket blinking. @@ -530,9 +551,16 @@ set splitbelow set splitright set title +set completeopt=menuone,noinsert,noselect " Quicker window movement nnoremap j nnoremap k nnoremap h nnoremap l + +" telescope +nnoremap lua require('telescope.builtin').find_files() +nnoremap g lua require('telescope.builtin').live_grep() +nnoremap b lua require('telescope.builtin').buffers() +nnoremap h lua require('telescope.builtin').help_tags() diff --git a/config/redshift.conf b/config/redshift.conf index 4e874cb..fe087db 100644 --- a/config/redshift.conf +++ b/config/redshift.conf @@ -11,8 +11,8 @@ transition=1 ; Set the screen brightness. Default is 1.0 ;brightness=0.9 ; It is also possible to use different settings for day and night since version 1.8. -;brightness-day=0.7 -brightness-night=0.8 +;brightness-day=1.0 +brightness-night=0.7 ; Set the screen gamma (for all colors, or each color channel individually) ;gamma=0.9 diff --git a/config/youtube-dl/config b/config/youtube-dl/config new file mode 100644 index 0000000..33c3b04 --- /dev/null +++ b/config/youtube-dl/config @@ -0,0 +1,6 @@ +--prefer-free-formats +--mark-watched +-f mp4+best/mp4+bestaudio/bestvideo+bestaudio/best +--retries infinite +--socket-timeout 1 +--external-downloader aria2c diff --git a/profile b/profile index e4ef4eb..d92e2b6 100644 --- a/profile +++ b/profile @@ -60,3 +60,7 @@ fi if [ -d $HOME/bin ] ; then export PATH="$HOME/bin:$PATH" fi + +if [ -d $HOME/.nimble/bin ] ; then + export PATH="$HOME/.nimble/bin:$PATH" +fi diff --git a/xinitrc b/xinitrc index 0899bf2..b09cfe5 100755 --- a/xinitrc +++ b/xinitrc @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash export BROWSER=browser export TERMINAL=st @@ -21,9 +21,9 @@ xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Button" 2 xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Timeout" 200 xinput set-prop "TPPS/2 IBM TrackPoint" "Evdev Wheel Emulation Axes" 6 7 4 5 -# xinput set-prop "Primax Kensington Eagle Trackball" "Evdev Middle Button Emulation" 1 +xinput set-prop "Primax Kensington Eagle Trackball" "Evdev Middle Button Emulation" 1 # exec ck-launch-session dbus-launch xrdb -merge ~/.Xresources -exec dbus-launch --exit-with-session i3 > $HOME/log/i3.txt 2>&1 +exec dbus-launch --exit-with-x11 i3 > $HOME/log/i3.txt 2>&1