Advertisement
muppi090909

Untitled

Mar 1st, 2022
1,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 34.90 KB | None | 0 0
  1. call plug#begin('~/.config/nvim/plugged')
  2. "debugger
  3. Plug 'puremourning/vimspector'
  4. " Lsp and completion sutff
  5. Plug 'neovim/nvim-lspconfig'
  6. Plug 'onsails/diaglist.nvim'
  7. Plug 'onsails/lspkind-nvim'
  8. Plug 'nvim-lua/completion-nvim'
  9. Plug 'williamboman/nvim-lsp-installer'
  10. Plug 'ray-x/lsp_signature.nvim'
  11. " Plug 'tzachar/cmp-tabnine', { 'do': './install.sh' }
  12. Plug 'vlime/vlime', {'rtp': 'vim/'}
  13. " Litee
  14. Plug 'ldelossa/litee.nvim'
  15. Plug 'ldelossa/litee-calltree.nvim'
  16. Plug 'ldelossa/litee-symboltree.nvim'
  17. "virtualenv
  18. Plug 'PieterjanMontens/vim-pipenv'
  19. Plug 'plytophogy/vim-virtualenv'
  20. " Scrollbar
  21. Plug 'dstein64/nvim-scrollview'
  22. " Completion framework
  23. Plug 'hrsh7th/nvim-cmp'
  24. " surround
  25. Plug 'tpope/vim-surround'
  26. " LSP completion source for nvim-cmp
  27. Plug 'hrsh7th/cmp-nvim-lsp'
  28. " colorizer
  29. Plug 'norcalli/nvim-colorizer.lua'
  30. Plug 'rust-lang/rust.vim'
  31. " Parentheses
  32. Plug 'cohama/lexima.vim'
  33. " wildmenu
  34. if has('nvim')
  35.   function! UpdateRemotePlugins(...)
  36.     " Needed to refresh runtime files
  37.     let &rtp=&rtp
  38.     UpdateRemotePlugins
  39.   endfunction
  40.  
  41.   Plug 'gelguy/wilder.nvim', { 'do': function('UpdateRemotePlugins') }
  42. else
  43.   Plug 'gelguy/wilder.nvim'
  44.  
  45.   " To use Python remote plugin features in Vim, can be skipped
  46.   Plug 'roxma/nvim-yarp'
  47.   Plug 'roxma/vim-hug-neovim-rpc'
  48. endif
  49. " treesitter
  50. Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
  51. Plug 'nvim-treesitter/nvim-treesitter-textobjects'
  52. Plug 'David-Kunz/treesitter-unit'
  53. Plug 'nvim-treesitter/nvim-treesitter-refactor'
  54. Plug 'nvim-treesitter/playground'
  55. " status bar
  56. Plug 'arkav/lualine-lsp-progress'
  57. Plug 'akinsho/bufferline.nvim'
  58. Plug 'nvim-lualine/lualine.nvim'
  59. Plug 'kyazdani42/nvim-web-devicons'
  60.  
  61. " Snippet completion source for nvim-cmp
  62. Plug 'hrsh7th/cmp-vsnip'
  63. Plug 'ray-x/cmp-treesitter'
  64.  
  65. " Other usefull completion sources
  66. Plug 'hrsh7th/cmp-path'
  67. Plug 'hrsh7th/cmp-buffer'
  68. Plug 'hrsh7th/cmp-nvim-lsp-signature-help'
  69.  
  70. " See hrsh7th's other plugins for more completion sources!
  71. Plug 'tell-k/vim-autopep8'
  72. " To enable more of the features of rust-analyzer, such as inlay hints and more!
  73. Plug 'simrat39/rust-tools.nvim'
  74. " Snippet engine
  75. Plug 'hrsh7th/vim-vsnip'
  76. " multi cursor
  77. Plug 'mg979/vim-visual-multi', {'branch': 'master'}
  78. " Fuzzy finder
  79. Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  80. Plug 'junegunn/fzf.vim'
  81. Plug 'wookayin/fzf-ripgrep.vim'
  82. " Misc
  83. Plug 'nvim-lua/popup.nvim'
  84. Plug 'nvim-lua/plenary.nvim'
  85. Plug 'nvim-telescope/telescope.nvim'
  86. Plug 'tpope/vim-fugitive'
  87. Plug 'simrat39/symbols-outline.nvim'
  88. Plug 'tpope/vim-commentary'
  89. Plug 'ryanoasis/vim-devicons'
  90. Plug 'machakann/vim-highlightedyank'
  91. Plug 'purofle/vim-mindustry-logic'
  92. Plug 'morhetz/gruvbox'
  93. Plug 'mattn/emmet-vim'
  94. Plug 'frazrepo/vim-rainbow'
  95. Plug 'mcchrish/nnn.vim'
  96. Plug 'chentau/marks.nvim'
  97. Plug 'glepnir/dashboard-nvim', { 'on': 'Dashboard' }
  98. "code runner
  99. Plug 'xianzhon/vim-code-runner'
  100.  
  101. call plug#end()
  102. " Set completeopt to have a better completion experience
  103. " :help completeopt
  104. " menuone: popup even when there's only one match
  105. " noinsert: Do not insert text until a selection is made
  106. " noselect: Do not select, force user to select one from the menu
  107. " general settings
  108. set guicursor=v-c-sm:block,n-i-ci-ve:ver25,r-cr-o:hor20
  109. command -nargs=+ LspHover lua vim.lsp.buf.hover()
  110. set keywordprg=:LspHover
  111. lua require'bufferline'.setup{}
  112. lua << EOF
  113. require("diaglist").init({
  114.     -- optional settings
  115.     -- below are defaults
  116.     debug = false,
  117.  
  118.     -- increase for noisy servers
  119.     debounce_ms = 150,
  120. })
  121. EOF
  122. nmap <space>da <cmd>lua require('diaglist').open_all_diagnostics()<cr>
  123. nmap <space>db <cmd>lua require('diaglist').open_buffer_diagnostics()<cr>
  124. set nu
  125. function Pip_init()
  126. if filereadable("Pipfile")
  127. Pipenv
  128. endif
  129. endfunction
  130. au VimEnter * if exists('Pipenv') | :call Pip_init()
  131. set shadafile=/home/muppi/.local/share/nvim/shada/main.shada
  132. nnoremap <F8> :SymbolsOutline<CR>
  133. lua << EOF
  134. require'marks'.setup {
  135.   -- whether to map keybinds or not. default true
  136.   default_mappings = true,
  137.   -- which builtin marks to show. default {}
  138.   builtin_marks = { ".", "<", ">", "^" },
  139.   -- whether movements cycle back to the beginning/end of buffer. default true
  140.   cyclic = true,
  141.   -- whether the shada file is updated after modifying uppercase marks. default false
  142.   force_write_shada = true,
  143.   -- how often (in ms) to redraw signs/recompute mark positions.
  144.   -- higher values will have better performance but may cause visual lag,
  145.   -- while lower values may cause performance penalties. default 150.
  146.   refresh_interval = 250,
  147.   -- sign priorities for each type of mark - builtin marks, uppercase marks, lowercase
  148.   -- marks, and bookmarks.
  149.   -- can be either a table with all/none of the keys, or a single number, in which case
  150.   -- the priority applies to all marks.
  151.   -- default 10.
  152.   sign_priority = { lower=10, upper=15, builtin=8, bookmark=20 },
  153.   -- disables mark tracking for specific filetypes. default {}
  154.   excluded_filetypes = {},
  155.   -- marks.nvim allows you to configure up to 10 bookmark groups, each with its own
  156.   -- sign/virttext. Bookmarks can be used to group together positions and quickly move
  157.   -- across multiple buffers. default sign is '!@#$%^&*()' (from 0 to 9), and
  158.   -- default virt_text is "".
  159.   bookmark_0 = {
  160.     sign = "⚑",
  161.     virt_text = "hello world"
  162.   },
  163.   mappings = {}
  164. }
  165. EOF
  166. let g:rainbow_active = 1
  167. lua << EOF
  168. vim.g.symbols_outline = {
  169.     highlight_hovered_item = true,
  170.     show_guides = true,
  171.     auto_preview = true,
  172.     position = 'right',
  173.     relative_width = true,
  174.     width = 25,
  175.     auto_close = false,
  176.     show_numbers = false,
  177.     show_relative_numbers = false,
  178.     show_symbol_details = true,
  179.     preview_bg_highlight = 'Pmenu',
  180.     keymaps = { -- These keymaps can be a string or a table for multiple keys
  181.         close = {"<Esc>", "q"},
  182.         goto_location = "<Cr>",
  183.         focus_location = "o",
  184.         hover_symbol = "<C-space>",
  185.         toggle_preview = "<C>k",
  186.         rename_symbol = "r",
  187.         code_actions = "a",
  188.     },
  189.     lsp_blacklist = {},
  190.     symbol_blacklist = {},
  191.     symbols = {
  192.         File = {icon = "", hl = "TSURI"},
  193.         Module = {icon = "", hl = "TSNamespace"},
  194.         Namespace = {icon = "", hl = "TSNamespace"},
  195.         Package = {icon = "", hl = "TSNamespace"},
  196.         Class = {icon = "𝓒", hl = "TSType"},
  197.         Method = {icon = "ƒ", hl = "TSMethod"},
  198.         Property = {icon = "", hl = "TSMethod"},
  199.         Field = {icon = "", hl = "TSField"},
  200.         Constructor = {icon = "", hl = "TSConstructor"},
  201.         Enum = {icon = "ℰ", hl = "TSType"},
  202.         Interface = {icon = "ﰮ", hl = "TSType"},
  203.         Function = {icon = "", hl = "TSFunction"},
  204.         Variable = {icon = "", hl = "TSConstant"},
  205.         Constant = {icon = "", hl = "TSConstant"},
  206.         String = {icon = "𝓐", hl = "TSString"},
  207.         Number = {icon = "#", hl = "TSNumber"},
  208.         Boolean = {icon = "⊨", hl = "TSBoolean"},
  209.         Array = {icon = "", hl = "TSConstant"},
  210.         Object = {icon = "⦿", hl = "TSType"},
  211.         Key = {icon = "🔐", hl = "TSType"},
  212.         Null = {icon = "NULL", hl = "TSType"},
  213.         EnumMember = {icon = "", hl = "TSField"},
  214.         Struct = {icon = "𝓢", hl = "TSType"},
  215.         Operator = {icon = "+", hl = "TSOperator"},
  216.         TypeParameter = {icon = "𝙏", hl = "TSParameter"}
  217.     }
  218. }
  219. EOF
  220. syntax enable
  221. set autoindent
  222. set smartindent
  223. set modifiable
  224. set nowrap
  225. set noswapfile
  226. set nobackup
  227. set clipboard=unnamedplus
  228. set shell=zsh
  229. call wilder#setup({'modes': [':', '/', '?']})
  230. call wilder#setup({
  231.       \ 'modes': [':', '/', '?'],
  232.       \ 'next_key': '<Tab>',
  233.       \ 'previous_key': '<S-Tab>',
  234.       \ 'accept_key': '<Down>',
  235.       \ 'reject_key': '<Up>',
  236.       \ })
  237. " treesitter setup
  238. lua <<EOF
  239. require'nvim-treesitter.configs'.setup {
  240.   refactor = {
  241.     navigation = {
  242.       enable = true,
  243.       keymaps = {
  244.         goto_definition = "gnd",
  245.         list_definitions = "gnD",
  246.         list_definitions_toc = "gO",
  247.         goto_next_usage = "<C-*>",
  248.         goto_previous_usage = "<C-#>",
  249.       },
  250.     },
  251.   },
  252. }
  253. EOF
  254. lua << EOF
  255. require'nvim-treesitter.configs'.setup {
  256.   -- One of "all", "maintained" (parsers with maintainers), or a list of languages
  257.   ensure_installed = "maintained",
  258.  
  259.   -- Install languages synchronously (only applied to `ensure_installed`)
  260.   sync_install = false,
  261.  
  262.   -- List of parsers to ignore installing
  263.   ignore_install = { "javascript" },
  264.  
  265.   highlight = {
  266.     -- `false` will disable the whole extension
  267.     enable = true,
  268.  
  269.     -- list of language that will be disabled
  270.  
  271.     -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
  272.     -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
  273.     -- Using this option may slow down your editor, and you may see some duplicate highlights.
  274.     -- Instead of true it can also be a list of languages
  275.     additional_vim_regex_highlighting = false,
  276.   },
  277. }
  278. EOF
  279. lua <<EOF
  280. require'nvim-treesitter.configs'.setup {
  281.   textobjects = {
  282.     lsp_interop = {
  283.       enable = true,
  284.       border = 'none',
  285.       peek_definition_code = {
  286.         ["<leader>df"] = "@function.outer",
  287.         ["<leader>dF"] = "@class.outer",
  288.       },
  289.     },
  290.   },
  291. }
  292. EOF
  293. lua <<EOF
  294. require'nvim-treesitter.configs'.setup {
  295.   textobjects = {
  296.     move = {
  297.       enable = true,
  298.       set_jumps = true, -- whether to set jumps in the jumplist
  299.       goto_next_start = {
  300.         ["]m"] = "@function.outer",
  301.         ["]]"] = "@class.outer",
  302.       },
  303.       goto_next_end = {
  304.         ["]M"] = "@function.outer",
  305.         ["]["] = "@class.outer",
  306.       },
  307.       goto_previous_start = {
  308.         ["[m"] = "@function.outer",
  309.         ["[["] = "@class.outer",
  310.       },
  311.       goto_previous_end = {
  312.         ["[M"] = "@function.outer",
  313.         ["[]"] = "@class.outer",
  314.       },
  315.     },
  316.   },
  317. }
  318. EOF
  319.  
  320. " To enable more of the features of rust-analyzer, such as inlay hints and
  321. " more!
  322. lua << EOF
  323. require'nvim-treesitter.configs'.setup {
  324.   highlight = {
  325.     enable = true,
  326.     custom_captures = {
  327.       -- Highlight the @foo.bar capture group with the "Identifier" highlight group.
  328.       ["foo.bar"] = "Identifier",
  329.     },
  330.     -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
  331.     -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
  332.     -- Using this option may slow down your editor, and you may see some duplicate highlights.
  333.     -- Instead of true it can also be a list of languages
  334.     additional_vim_regex_highlighting = false,
  335.   },
  336. }
  337. EOF
  338. lua << EOF
  339. require'nvim-treesitter.configs'.setup {
  340.   incremental_selection = {
  341.     enable = true,
  342.     keymaps = {
  343.       init_selection = "gnn",
  344.       node_incremental = "grn",
  345.       scope_incremental = "grc",
  346.       node_decremental = "grm",
  347.     },
  348.   },
  349. }
  350. EOF
  351. lua << EOF
  352. require'nvim-treesitter.configs'.setup {
  353.   indent = {
  354.     enable = true
  355.   }
  356. }
  357. EOF
  358. lua <<EOF
  359. require'nvim-treesitter.configs'.setup {
  360.   refactor = {
  361.     highlight_definitions = {
  362.       enable = true,
  363.       -- Set to false if you have an `updatetime` of ~100.
  364.       clear_on_cursor_move = true,
  365.     },
  366.   },
  367. }
  368. EOF
  369. lua <<EOF
  370. require'nvim-treesitter.configs'.setup {
  371.   refactor = {
  372.     highlight_current_scope = { enable = true },
  373.   },
  374. }
  375. EOF
  376. lua <<EOF
  377. require'nvim-treesitter.configs'.setup {
  378.   refactor = {
  379.     smart_rename = {
  380.       enable = true,
  381.       keymaps = {
  382.         smart_rename = "grr",
  383.       },
  384.     },
  385.   },
  386. }
  387. EOF
  388. set foldmethod=expr
  389. set foldexpr=nvim_treesitter#foldexpr()
  390. nnoremap <leader>s :TSPlaygroundToggle<CR>
  391. cnoreabbrev term tabnew +term
  392. au BufRead,BufNewFile *.g4 setfiletype antlr4
  393. au BufRead,BufNewFile *.lisp setfiletype lisp
  394. nohl
  395. set mouse=niv
  396. let g:autopep8_disable_show_diff=1
  397. set nocompatible
  398. nmap <silent><leader>l <plug>CodeRunner
  399. let g:CodeRunnerCommandMap = {
  400.       \ 'python' : 'python3 $fileName',
  401.       \ 'rust' : 'cargo run',
  402.       \ 'lisp' : 'clisp $fileName',
  403.       \ 'asm' : 'nasm -f elf $fileName && ld -m elf_i386 -s -o $fileNameWithoutExt $fileNameWithoutExt.o && ./$fileNameWithoutExt && rm $fileNameWithoutExt'
  404.       \}
  405. " Code navigation shortcuts
  406. nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
  407. nnoremap <silent> K     <cmd>lua vim.lsp.buf.hover()<CR>
  408. nnoremap <silent> gD    <cmd>lua vim.lsp.buf.implementation()<CR>
  409. nnoremap <silent> 1gD   <cmd>lua vim.lsp.buf.type_definition()<CR>
  410. nnoremap <silent> gr    <cmd>lua vim.lsp.buf.references()<CR>
  411. nnoremap <silent> g0    <cmd>lua vim.lsp.buf.document_symbol()<CR>
  412. nnoremap <silent> gW    <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
  413. nnoremap <silent> gd    <cmd>lua vim.lsp.buf.definition()<CR>
  414. let g:code_runner_save_before_execute = 1
  415. cnoreabbrev refresh so ~/.config/nvim/init.vim
  416. colorscheme gruvbox
  417. " vimspector
  418. au BufRead,BufNewFile *.py cnoreabbrev debugger_init !cp ~/Templates/vimspector-python.json .vimspector.json
  419. au BufRead,BufNewFile *.rs cnoreabbrev debugger_init !cp ~/Templates/vimspector-rust.json .vimspector.json
  420. au BufRead,BufNewFile *.sh cnoreabbrev debugger_init !cp ~/Templates/vimspector-bash.json .vimspector.json
  421. cnoreabbrev debug_end call vimspector#Reset()
  422. cnoreabbrev watch VimspectorWatch
  423. nnoremap <Leader>dd :call vimspector#Launch()<CR>
  424. nnoremap <Leader>de :call vimspector#Reset()<CR>
  425. nnoremap <Leader>dc :call vimspector#Continue()<CR>
  426.  
  427. nnoremap <Leader>dt :call vimspector#ToggleBreakpoint()<CR>
  428. nnoremap <Leader>dT :call vimspector#ClearBreakpoints()<CR>
  429. nnoremap <leader>dat :call vimspector#ToggleAdvancedBreakpoint()<CR>
  430.  
  431. nmap <Leader>du <Plug>VimspectorStepOut
  432. nmap <Leader>di <Plug>VimspectorStepInto
  433. nmap <Leader>do <Plug>VimspectorStepOver
  434. " emmet
  435. au FileType html,css EmmetInstall
  436. let g:user_emmet_leader_key=','
  437. " fzf
  438. nnoremap <silent> <Leader>b :Buffers<CR>
  439. nnoremap <silent> <C-f> :Files<CR>
  440. set grepprg=/home/muppi/bin/ripgrep/target/release/rg\ --vimgrep\ --smart-case\ --follow\ --hidden
  441. nnoremap <silent> <Leader>f :RgFzf<CR>
  442. nnoremap <silent> <Leader>r :Rg<Cr>
  443. nnoremap <silent> <Leader>/ :BLines<CR>
  444. nnoremap <silent> <Leader>' :Marks<CR>
  445. nnoremap <silent> <Leader>g :Commits<CR>
  446. nnoremap <silent> <Leader>H :Helptags<CR>
  447. nnoremap <silent> <Leader>hh :History<CR>
  448. nnoremap <silent> <Leader>h: :History:<CR>
  449. nnoremap <silent> <Leader>h/ :History/<CR>
  450. " Set the basic sizes
  451. let g:vimspector_sidebar_width = 80
  452. let g:vimspector_code_minwidth = 85
  453. let g:vimspector_terminal_minwidth = 40
  454. function! s:CustomiseUI()
  455.  " Customise the basic UI...
  456.  
  457.  " Close the output window
  458.  call win_gotoid( g:vimspector_session_windows.output )
  459.  q
  460. endfunction
  461.  
  462. augroup MyVimspectorUICustomistaion
  463.  autocmd!
  464.  autocmd User VimspectorUICreated call s:CustomiseUI()
  465. augroup END
  466.  
  467. let g:vimspector_enable_mappings = 'VISUAL_STUDIO'
  468. cnoreabbrev debug_end call vimspector#Reset()
  469. xmap <Leader>di <Plug>VimspectorBalloonEval
  470. cnoreabbrev debug_map h vimspector-visual-studio-vscode
  471. " status bar
  472. lua << EOF
  473. local colors = {
  474.  yellow = '#ECBE7B',
  475.  cyan = '#008080',
  476.  darkblue = '#081633',
  477.  green = '#98be65',
  478.  orange = '#FF8800',
  479.  violet = '#a9a1e1',
  480.  magenta = '#c678dd',
  481.  blue = '#51afef',
  482.  red = '#ec5f67'
  483. }
  484. local function getWords()
  485.  return tostring(vim.fn.wordcount().words)
  486. end
  487. local config = {
  488.  options = {
  489.    icons_enabled = true,
  490.    theme = 'gruvbox',
  491.    component_separators = {'', ''},
  492.    section_separators = {'', ''},
  493.    disabled_filetypes = {}
  494.    },
  495.  sections = {
  496.    lualine_a = {'mode'},
  497.    lualine_b = {
  498.        
  499.      },
  500.    lualine_c = {},
  501.    lualine_x = {{ "diagnostics", sources = { "nvim_lsp" }},
  502.      "filename",
  503.      { getWords }, "location"},
  504.    lualine_y = {'encoding', 'fileformat', 'filetype'},
  505.    lualine_z = {'branch'},
  506.    },
  507.  inactive_sections = {
  508.    lualine_a = {},
  509.    lualine_b = {},
  510.    lualine_c = {'filename'},
  511.    lualine_x = {},
  512.    lualine_y = {},
  513.    lualine_z = {}
  514.  },
  515.  tabline = {},
  516.  extensions = {}
  517. }
  518. -- Inserts a component in lualine_c at left section
  519. local function ins_left(component)
  520.  table.insert(config.sections.lualine_c, component)
  521. end
  522.  
  523. -- Inserts a component in lualine_x ot right section
  524. local function ins_right(component)
  525.  table.insert(config.sections.lualine_x, component)
  526. end
  527.  
  528. ins_left {
  529.     'lsp_progress',
  530.     display_components = { 'lsp_client_name', { 'title', 'percentage', 'message' }},
  531.     -- With spinner
  532.     -- display_components = { 'lsp_client_name', 'spinner', { 'title', 'percentage', 'message' }},
  533.     colors = {
  534.       percentage  = colors.cyan,
  535.       title  = colors.cyan,
  536.       message  = colors.cyan,
  537.       spinner = colors.cyan,
  538.       lsp_client_name = colors.magenta,
  539.       use = true,
  540.     },
  541.     separators = {
  542.         component = ' ',
  543.         progress = ' | ',
  544.         message = { pre = '(', post = ')'},
  545.         percentage = { pre = '', post = '%% ' },
  546.         title = { pre = '', post = ': ' },
  547.         lsp_client_name = { pre = '[', post = ']' },
  548.         spinner = { pre = '', post = '' },
  549.         message = { commenced = 'In Progress', completed = 'Completed' },
  550.     },
  551.     display_components = { 'lsp_client_name', 'spinner', { 'title', 'percentage', 'message' } },
  552.     timer = { progress_enddelay = 500, spinner = 1000, lsp_client_name_enddelay = 1000 },
  553.     spinner_symbols = { '🌑 ', '🌒 ', '🌓 ', '🌔 ', '🌕 ', '🌖 ', '🌗 ', '🌘 ' },
  554. }
  555. require('lualine').setup(config)
  556. EOF
  557. " misc
  558. set termguicolors
  559. lua require 'colorizer'.setup()
  560. let g:loaded_python_provider = 0
  561. let g:python3_host_prog  = '/usr/bin/python3.9'
  562. set background=dark " use dark mode
  563. " set highlight duration time to 1000 ms, i.e., 1 second
  564. let g:highlightedyank_highlight_duration = 1000
  565. set encoding=utf-8
  566. set tabstop=4
  567. set softtabstop=4
  568. set shiftwidth=4
  569. set textwidth=79
  570. set expandtab
  571. set autoindent
  572. set fileformat=unix
  573. au BufRead,BufNewFile *.py cnoreabbrev format Autopep8
  574. au BufRead,BufNewFile *.rs cnoreabbrev format RustFmt
  575. " file tree
  576. nmap <F2> :NnnExplorer<CR>
  577. tmap <F2> :NnnExplorer<CR>
  578.  
  579. " Tabs
  580. let mapleader = "\\"
  581. nmap <leader>1 :bp<CR>
  582. nmap <leader>2 :bn<CR>
  583. nmap <C-w> :sil! bd!<CR>
  584. set completeopt=menuone,noinsert,noselect
  585.  
  586. " Avoid showing extra messages when using completion
  587. set shortmess+=c
  588.  
  589. "split navigations
  590. nnoremap <C-J> <C-W><C-J>
  591. nnoremap <C-k> <C-w><C-k>
  592. nnoremap <C-L> <C-W><C-L>
  593. nnoremap <C-H> <C-W><C-H>
  594. " Configure LSP through rust-tools.nvim plugin.
  595. " rust-tools will configure and enable certain LSP features for us.
  596. " See https://github.com/simrat39/rust-tools.nvim#configuration
  597. nnoremap <leader>c :lua vim.lsp.buf.code_action()<CR>
  598.  
  599. lua << EOF
  600. local lsp_installer = require "nvim-lsp-installer"
  601.  
  602. -- Include the servers you want to have installed by default below
  603. local servers = {
  604.  "bashls",
  605.  "pyright",
  606.  "rust_analyzer",
  607.  "vimls",
  608.  "asm_lsp"
  609. }
  610.  
  611. for _, name in pairs(servers) do
  612.  local server_is_found, server = lsp_installer.get_server(name)
  613.  if server_is_found then
  614.             if not server:is_installed() then
  615.               print("Installing " .. name)
  616.               server:install()
  617.             end
  618.           end
  619.         end
  620. EOF
  621.  
  622. lua << EOF
  623.     local lsp_installer = require("nvim-lsp-installer")
  624.  
  625.     lsp_installer.on_server_ready(function(server)
  626.  
  627.     local opts = {}
  628.  
  629.     if server.name == "rust_analyzer" then
  630.             require("rust-tools").setup({
  631.         tools = { -- rust-tools options
  632.             -- Automatically set inlay hints (type hints)
  633.             autoSetHints = true,
  634.    
  635.             -- Whether to show hover actions inside the hover window
  636.             -- This overrides the default hover handler
  637.             hover_with_actions = true,
  638.    
  639.             -- how to execute terminal commands
  640.             -- options right now: termopen / quickfix
  641.             executor = require("rust-tools/executors").termopen,
  642.    
  643.             runnables = {
  644.                 -- whether to use telescope for selection menu or not
  645.                 use_telescope = true
  646.    
  647.                 -- rest of the opts are forwarded to telescope
  648.             },
  649.    
  650.             debuggables = {
  651.                 -- whether to use telescope for selection menu or not
  652.                 use_telescope = true
  653.    
  654.                 -- rest of the opts are forwarded to telescope
  655.             },
  656.    
  657.             -- These apply to the default RustSetInlayHints command
  658.             inlay_hints = {
  659.    
  660.                 -- Only show inlay hints for the current line
  661.                 only_current_line = false,
  662.    
  663.                 -- Event which triggers a refersh of the inlay hints.
  664.                 -- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but
  665.                 -- not that this may cause  higher CPU usage.
  666.                 -- This option is only respected when only_current_line and
  667.                 -- autoSetHints both are true.
  668.                 only_current_line_autocmd = "CursorHold",
  669.    
  670.                 -- wheter to show parameter hints with the inlay hints or not
  671.                 show_parameter_hints = true,
  672.    
  673.                 -- prefix for parameter hints
  674.                 parameter_hints_prefix = "<- ",
  675.    
  676.                 -- prefix for all the other hints (type, chaining)
  677.                 other_hints_prefix = "=> ",
  678.    
  679.                 -- whether to align to the length of the longest line in the file
  680.                 max_len_align = false,
  681.    
  682.                 -- padding from the left if max_len_align is true
  683.                 max_len_align_padding = 1,
  684.    
  685.                 -- whether to align to the extreme right or not
  686.                 right_align = false,
  687.    
  688.                 -- padding from the right if right_align is true
  689.                 right_align_padding = 7,
  690.    
  691.                 -- The color of the hints
  692.                 highlight = "Comment",
  693.             },
  694.    
  695.             hover_actions = {
  696.                 -- the border that is used for the hover window
  697.                 -- see vim.api.nvim_open_win()
  698.                 border = {
  699.                     {"╭", "FloatBorder"}, {"─", "FloatBorder"},
  700.                     {"╮", "FloatBorder"}, {"│", "FloatBorder"},
  701.                     {"╯", "FloatBorder"}, {"─", "FloatBorder"},
  702.                     {"╰", "FloatBorder"}, {"│", "FloatBorder"}
  703.                 },
  704.    
  705.                 -- whether the hover action window gets automatically focused
  706.                 auto_focus = false
  707.             },
  708.    
  709.             -- settings for showing the crate graph based on graphviz and the dot
  710.             -- command
  711.             crate_graph = {
  712.                 -- Backend used for displaying the graph
  713.                 -- see: https://graphviz.org/docs/outputs/
  714.                 -- default: x11
  715.                 backend = "x11",
  716.                 -- where to store the output, nil for no output stored (relative
  717.                 -- path from pwd)
  718.                 -- default: nil
  719.                 output = nil,
  720.                 -- true for all crates.io and external crates, false only the local
  721.                 -- crates
  722.                 -- default: true
  723.                 full = true,
  724.             }
  725.         },
  726.    
  727.         -- all the opts to send to nvim-lspconfig
  728.         -- these override the defaults set by rust-tools.nvim
  729.         -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
  730.         server = {
  731.             -- standalone file support
  732.             -- setting it to false may improve startup time
  733.             standalone = true,
  734.             cmd =  { "/home/muppi/.local/share/nvim/lsp_servers/rust/rust-analyzer" },
  735.         }, -- rust-analyer options
  736.    on_attach = on_attach
  737.     })
  738.     return
  739.     elseif server.name == "html" then
  740.         local capabilities = vim.lsp.protocol.make_client_capabilities()
  741.         capabilities.textDocument.completion.completionItem.snippetSupport = true
  742.         opts = {capabilities=capabilities,on_attach = on_attach, cmd={"/home/muppi/.local/share/nvim/lsp_servers/html/node_modules/vscode-langservers-extracted/bin/vscode-html-language-server", "--stdio"}}
  743.    elseif server.name == "asm_lsp" then
  744.        opts = {cmd={"/home/muppi/.local/share/nvim/lsp_servers/asm_lsp/bin/asm-lsp"}}
  745.     end
  746.     -- This setup() function is exactly the same as lspconfig's setup function.
  747.     -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/ADVANCED_README.md
  748.      cfg = {
  749.   debug = false, -- set to true to enable debug logging
  750.   log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log", -- log dir when debug is on
  751.   -- default is  ~/.cache/nvim/lsp_signature.log
  752.   verbose = false, -- show debug line number
  753.  
  754.   bind = true, -- This is mandatory, otherwise border config won't get registered.
  755.               -- If you want to hook lspsaga or other signature handler, pls set to false
  756.  doc_lines = 10, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated);
  757.                 -- set to 0 if you DO NOT want any API comments be shown
  758.                 -- This setting only take effect in insert mode, it does not affect signature help in normal
  759.                 -- mode, 10 by default
  760.  
  761.  floating_window = true, -- show hint in a floating window, set to false for virtual text only mode
  762.  
  763.  floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note:
  764.  -- will set to true when fully tested, set to false will use whichever side has more space
  765.  -- this setting will be helpful if you do not want the PUM and floating win overlap
  766.  
  767.  floating_window_off_x = 1, -- adjust float windows x position.
  768.  floating_window_off_y = 1, -- adjust float windows y position.
  769.  
  770.  
  771.  fix_pos = false,  -- set to true, the floating window will not auto-close until finish all parameters
  772.  hint_enable = true, -- virtual hint enable
  773.  hint_prefix = "🐼 ",  -- Panda for parameter
  774.  hint_scheme = "String",
  775.  hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight
  776.  max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down
  777.                   -- to view the hiding contents
  778.  max_width = 80, -- max_width of signature floating_window, line will be wrapped if exceed max_width
  779.  handler_opts = {
  780.    border = "rounded"   -- double, rounded, single, shadow, none
  781.  },
  782.  
  783.  always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58
  784.  
  785.  auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil.
  786.  extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
  787.  zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom
  788.  
  789.  padding = '', -- character to pad on left and right of signature can be ' ', or '|'  etc
  790.  
  791.  transparency = nil, -- disabled by default, allow floating win transparent value 1~100
  792.  shadow_blend = 36, -- if you using shadow as border use this set the opacity
  793.  shadow_guibg = 'Black', -- if you using shadow as border use this set the color e.g. 'Green' or '#121315'
  794.  timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency
  795.  toggle_key = nil -- toggle signature on and off in insert mode,  e.g. toggle_key = '<M-x>'
  796. }
  797.  
  798. -- recommended:
  799. require'lsp_signature'.setup(cfg) -- no need to specify bufnr if you don't use toggle_key
  800.  
  801. -- You can also do this inside lsp on_attach
  802. -- note: on_attach deprecated
  803. require'lsp_signature'.on_attach(cfg, bufnr) -- no need to specify bufnr if you don't use toggle_key
  804. server:setup(opts)
  805. end)
  806. EOF
  807. nmap <silent> <C-_> gcc
  808. " See https://github.com/hrsh7th/nvim-cmp#basic-configuration
  809. lua << EOF
  810. local cmp = require'cmp'
  811. local lspkind = require('lspkind').init({
  812.    mode = 'symbol_text',
  813.    symbol_map = {
  814.    Text = '  ',
  815.  Method = '  ',
  816.  Function = '  ',
  817.  Constructor = '  ',
  818.  Field = '  ',
  819.  Variable = '  ',
  820.  Class = '  ',
  821.  Interface = '  ',
  822.  Module = '  ',
  823.  Property = '  ',
  824.  Unit = '  ',
  825.  Value = '  ',
  826.  Enum = '  ',
  827.  Keyword = '  ',
  828.  Snippet = '  ',
  829.  Color = '  ',
  830.  File = '  ',
  831.  Reference = '  ',
  832.  Folder = '  ',
  833.  EnumMember = '  ',
  834.  Constant = '  ',
  835.  Struct = '  ',
  836.  Event = '  ',
  837.  Operator = '',
  838.  TypeParameter = '  ',
  839.  
  840.  }})
  841. cmp.setup({
  842.  -- Enable LSP snippets
  843.  formatting = {
  844.       format = require'lspkind'.cmp_format({
  845.        mode = 'symbol',
  846.      maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
  847.          menu = ({
  848.          buffer = "[Buffer]",
  849.          nvim_lsp = "[LSP]",
  850.          cmp_tabinine = "[TabNine]",
  851.         path = "[Path]",
  852.         treesitter = "[TreeSitter]"
  853.        })
  854.       }),
  855.     },
  856.  snippet = {
  857.    expand = function(args)
  858.        vim.fn["vsnip#anonymous"](args.body)
  859.    end,
  860.  },
  861.  mapping = {
  862.    ['<C-p>'] = cmp.mapping.select_prev_item(),
  863.    ['<C-n>'] = cmp.mapping.select_next_item(),
  864.    -- Add tab support
  865.    ['<S-Tab>'] = cmp.mapping.select_prev_item(),
  866.    ['<Tab>'] = cmp.mapping.select_next_item(),
  867.    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
  868.    ['<C-f>'] = cmp.mapping.scroll_docs(4),
  869.    ['<C-Space>'] = cmp.mapping.complete(),
  870.    ['<C-e>'] = cmp.mapping.close(),
  871.    ['<CR>'] = cmp.mapping.confirm({
  872.      behavior = cmp.ConfirmBehavior.Insert,
  873.      select = true,
  874.    })
  875.  },
  876.  
  877.  -- Installed sources
  878.  sources = {
  879.    { name = 'nvim_lsp' },
  880.    { name = 'vsnip' },
  881.    { name = 'path' },
  882.    { name = 'buffer' },
  883.    -- { name = 'cmp_tabnine'  },
  884.    { name = 'treesitter' },
  885.    { name = 'nvim_lsp_signature_help' }
  886.  },
  887. })
  888. --   tabnine = require('cmp_tabnine.config')
  889. --   tabnine:setup({
  890. --   max_lines = 1000;
  891. --   max_num_results = 20;
  892. --   sort = true;
  893. --   run_on_every_keystroke = true;
  894. --   snippet_placeholder = '..';
  895. -- })
  896. EOF
  897. " au BufRead,BufNew *.lisp lua require'cmp'.setup({enabled=false})
  898. " have a fixed column for the diagnostics to appear in
  899. " this removes the jitter when warnings/errors flow in
  900. set signcolumn=yes
  901. function! Smart_TabComplete()
  902.  let line = getline('.')                         " current line
  903.  
  904.  let substr = strpart(line, -1, col('.')+1)      " from the start of the current
  905.                                                  " line to one character right
  906.                                                  " of the cursor
  907.  let substr = matchstr(substr, "[^ \t]*$")       " word till cursor
  908.  if (strlen(substr)==0)                          
  909.    return "\<tab>"
  910.  endif
  911.  return "\<C-X>\<C-O>"                         " plugin matching
  912. endfunction
  913. au BufRead,BufNewFile *.lisp inoremap <tab> <c-r>=Smart_TabComplete()<CR>
  914. " Set updatetime for CursorHold
  915. " 300ms of no cursor movement to trigger CursorHold
  916. set updatetime=300
  917. " Goto previous/next diagnostic warning/error
  918. nnoremap <silent> g[ <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
  919. nnoremap <silent> g] <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
  920. nnoremap <silent> ga    <cmd>lua vim.lsp.buf.code_action()<CR>
  921. " dashboard
  922. nmap <Leader>ss :<C-u>SessionSave<CR>
  923. nmap <Leader>sl :<C-u>SessionLoad<CR>
  924. nnoremap <silent> <Leader>fh :DashboardFindHistory<CR>
  925. nnoremap <silent> <Leader>ff :DashboardFindFile<CR>
  926. nnoremap <silent> <Leader>tc :DashboardChangeColorscheme<CR>
  927. nnoremap <silent> <Leader>fa :DashboardFindWord<CR>
  928. nnoremap <silent> <Leader>fb :DashboardJumpMark<CR>
  929. nnoremap <silent> <Leader>cn :DashboardNewFile<CR>
  930. let g:dashboard_default_executive='fzf'
  931. nnoremap <space>f <cmd>lua vim.lsp.buf.formatting()<CR>
  932. lua << EOF
  933. -- configure the litee.nvim library
  934. require('litee.lib').setup({
  935.    tree = {
  936.        icon_set = "codicons"
  937.    },
  938.    panel = {
  939.        orientation = "right",
  940.        panel_size  = 30
  941.    },
  942.    term = {
  943.        position = "bottom",
  944.        term_size = 15,
  945.    }
  946. })
  947. require('litee.symboltree').setup({
  948.    icon_set = "codicons",
  949.    hide_cursor = false,
  950. })
  951. require('litee.calltree').setup({
  952.    icon_set = "codicons",
  953.    hide_cursor = false,
  954. })
  955.  
  956. local opts = { silent = true }
  957. -- litee.lib mappings
  958. vim.api.nvim_set_keymap("n", "<C-t>",   ":LTPanel<cr>", opts)
  959. vim.api.nvim_set_keymap("n", "<C-t>t",  ":LTPanel<cr>", opts)
  960. vim.api.nvim_set_keymap("n", "<leader>tm", ":LTTerm<cr>", opts)
  961. vim.api.nvim_set_keymap("n", "<C-t>h",  ":LTClearJumpHL<cr>", opts)
  962.  
  963. -- calltree specific commands
  964. vim.api.nvim_set_keymap("n", "<C-h>o",     ":LTOpenToCalltree<cr>", opts)
  965. vim.api.nvim_set_keymap("n", "<C-h>oo",    ":LTPopOutCalltree<cr>", opts)
  966. vim.api.nvim_set_keymap("n", "<C-h>n",     ":LTNextCalltree<cr>", opts)
  967. vim.api.nvim_set_keymap("n", "<C-h>p",     ":LTPrevCalltree<cr>", opts)
  968. vim.api.nvim_set_keymap("n", "<C-h>e",     ":LTExpandCalltree<cr>", opts)
  969. vim.api.nvim_set_keymap("n", "<C-h>c",     ":LTCollapseCalltree<cr>", opts)
  970. vim.api.nvim_set_keymap("n", "<C-h>C",     ":LTCollapseAllCalltree<cr>", opts)
  971. vim.api.nvim_set_keymap("n", "<C-h>f",     ":LTFocusCalltree<cr>", opts)
  972. vim.api.nvim_set_keymap("n", "<C-h>S",     ":LTSwitchCalltree<cr>", opts)
  973. vim.api.nvim_set_keymap("n", "<C-h>j",     ":LTJumpCalltree<cr>", opts)
  974. vim.api.nvim_set_keymap("n", "<C-h>s",     ":LTJumpCalltreeSplit<cr>", opts)
  975. vim.api.nvim_set_keymap("n", "<C-h>v",     ":LTJumpCalltreeVSplit<cr>", opts)
  976. vim.api.nvim_set_keymap("n", "<C-h>t",     ":LTJumpCalltreeTab<cr>", opts)
  977. vim.api.nvim_set_keymap("n", "<C-h>h",     ":LTHoverCalltree<cr>", opts)
  978. vim.api.nvim_set_keymap("n", "<C-h>d",     ":LTDetailsCalltree<cr>", opts)
  979. vim.api.nvim_set_keymap("n", "<C-h>x",     ":LTCloseCalltree<cr>", opts)
  980.  
  981. -- symboltree specific commands
  982. vim.api.nvim_set_keymap("n", "<C-s>o", ":LTOpenToSymboltree<cr>", opts)
  983. vim.api.nvim_set_keymap("n", "<C-s>oo", ":LTPopOutSymboltree<cr>", opts)
  984. vim.api.nvim_set_keymap("n", "<C-s>n", ":LTNextSymboltree<cr>", opts)
  985. vim.api.nvim_set_keymap("n", "<C-s>p", ":LTPrevSymboltree<cr>", opts)
  986. vim.api.nvim_set_keymap("n", "<C-s>e", ":LTExpandSymboltree<cr>", opts)
  987. vim.api.nvim_set_keymap("n", "<C-s>c", ":LTCollapseSymboltree<cr>", opts)
  988. vim.api.nvim_set_keymap("n", "<C-s>C", ":LTCollapseAllSymboltree<cr>", opts)
  989. vim.api.nvim_set_keymap("n", "<C-s>j", ":LTJumpSymboltree<cr>", opts)
  990. vim.api.nvim_set_keymap("n", "<C-s>s", ":LTJumpSymboltreeSplit<cr>", opts)
  991. vim.api.nvim_set_keymap("n", "<C-s>v", ":LTJumpSymboltreeVSplit<cr>", opts)
  992. vim.api.nvim_set_keymap("n", "<C-s>t", ":LTJumpSymboltreeTab<cr>", opts)
  993. vim.api.nvim_set_keymap("n", "<C-s>h", ":LTHoverSymboltree<cr>", opts)
  994. vim.api.nvim_set_keymap("n", "<C-s>d", ":LTDetailsSymboltree<cr>", opts)
  995. vim.api.nvim_set_keymap("n", "<C-s>x", ":LTCloseSymboltree<cr>", opts)
  996.  
  997. vim.api.nvim_set_keymap("n", "<C-l>o", "<cmd>lua require('litee.lib.lsp.wrappers').buf_outgoing_calls()<CR>", opts)
  998. vim.api.nvim_set_keymap("n", "<C-l>i", "<cmd>lua require('litee.lib.lsp.wrappers').buf_incoming_calls()<CR>", opts)
  999. vim.api.nvim_set_keymap("n", "<C-l>s", "<cmd>lua require('litee.lib.lsp.wrappers').buf_document_symbol()<CR>", opts)
  1000. vim.api.nvim_set_keymap("i", "<C-l>o", "<cmd>lua require('litee.lib.lsp.wrappers').buf_outgoing_calls()<CR>", opts)
  1001. vim.api.nvim_set_keymap("i", "<C-l>i", "<cmd>lua require('litee.lib.lsp.wrappers').buf_incoming_calls()<CR>", opts)
  1002. vim.api.nvim_set_keymap("i", "<C-l>s", "<cmd>lua require('litee.lib.lsp.wrappers').buf_document_symbol()<CR>", opts)
  1003. -- configure litee-calltree.nvim
  1004. require('litee.calltree').setup({})
  1005. -- configure litee-symboltree.nvim
  1006. require('litee.symboltree').setup({})
  1007. EOF
  1008. autocmd VimEnter,VimLeavePre,BufNew,BufNewFile,BufDelete * delmarks 0-9 |  wshada! | wshada
  1009. if eval("@%") == ""
  1010.    Dashboard
  1011. endif
  1012.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement