Browse Source

new stuff

Chris 4 năm trước cách đây
mục cha
commit
ddb47a5d74
6 tập tin đã thay đổi với 98 bổ sung140 xóa
  1. 2 2
      init.vim
  2. 20 67
      keys/which-key.vim
  3. 64 67
      lua/plugins/telescope-config.lua
  4. 7 3
      plug-config/lsp-config.vim
  5. 1 1
      plug-config/rnvimr.vim
  6. 4 0
      vim-plug/plugins.vim

+ 2 - 2
init.vim

@@ -25,7 +25,6 @@ else
   source ~/.config/nvim/themes/nvcode.vim
 
   " Plugin Configuration
-  luafile ~/.config/nvim/lua/lsp/general-ls.lua
   source ~/.config/nvim/keys/which-key.vim
   source ~/.config/nvim/plug-config/vim-commentary.vim
   source ~/.config/nvim/plug-config/rnvimr.vim
@@ -48,6 +47,8 @@ else
   source ~/.config/nvim/plug-config/lsp-saga.vim
   source ~/.config/nvim/plug-config/lightbulb.vim
   source ~/.config/nvim/lua/lsp-wrapper.vim
+  source ~/.config/nvim/plug-config/lsp-config.vim
+  luafile ~/.config/nvim/lua/lsp/general-ls.lua
   luafile ~/.config/nvim/lua/plugins/galaxyline-config.lua
   luafile ~/.config/nvim/lua/plugins/nvimtree-config.lua
   luafile ~/.config/nvim/lua/plugins/treesitter-config.lua
@@ -57,7 +58,6 @@ else
   luafile ~/.config/nvim/lua/plugins/compe-config.lua
   luafile ~/.config/nvim/lua/plugins/lspsaga-config.lua
   " LSP: https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
-  source ~/.config/nvim/plug-config/lsp-config.vim
   luafile ~/.config/nvim/lua/lsp/lsp-config.lua
   luafile ~/.config/nvim/lua/lsp/lua-ls.lua
   luafile ~/.config/nvim/lua/lsp/python-ls.lua

+ 20 - 67
keys/which-key.vim

@@ -177,10 +177,10 @@ let g:which_key_map.s = {
       \ 'a' : [':Telescope lsp_code_actions'            , 'code_actions'],
       \ 'A' : [':Telescope builtin'                     , 'all'],
       \ 'b' : [':Telescope buffers'                     , 'buffers'],
-      \ 'B' : [':Telescope git_branches'                , 'git_branches'],
+      \ 'B' : [':Telescope git_branches'                , 'git branches'],
       \ 'd' : [':Telescope lsp_document_diagnostics'    , 'document_diagnostics'],
       \ 'D' : [':Telescope lsp_workspace_diagnostics'   , 'workspace_diagnostics'],
-      \ 'c' : [':Telescope git_bcommits'                , 'git_bcommits'],
+      \ 'c' : [':Telescope git_commits'                 , 'git_commits'],
       \ 'C' : [':Telescope git_bcommits'                , 'git_bcommits'],
       \ 'f' : [':Telescope find_files'                  , 'files'],
       \ 'F' : [':Telescope git_files'                   , 'git_files'],
@@ -188,12 +188,13 @@ let g:which_key_map.s = {
       \ 'G' : [':Telescope current_buffer_tags'         , 'buffer_tags'],
       \ 'h' : [':Telescope command_history'             , 'history'],
       \ 'H' : [':Telescope help_tags'                   , 'help_tags'],
+      \ 'i' : [':Telescope media_files'                 , 'media files'],
       \ 'k' : [':Telescope keymaps'                     , 'keymaps'],
       \ 'l' : [':Telescope loclist'                     , 'loclist'],
       \ 'm' : [':Telescope marks'                       , 'marks'],
+      \ 'M' : [':Telescope man_pages'                   , 'man_pages'],
       \ 'o' : [':Telescope vim_options'                 , 'vim_options'],
       \ 'O' : [':Telescope oldfiles'                    , 'oldfiles'],
-      \ 'M' : [':Telescope man_pages'                   , 'man_pages'],
       \ 'p' : [':Telescope fd'                          , 'fd'],
       \ 'P' : [':Telescope spell_suggest'               , 'spell_suggest'],
       \ 's' : [':Telescope git_status'                  , 'git_status'],
@@ -248,9 +249,6 @@ let g:which_key_map.g = {
       \ }
       " \ 'A' : [':Git add %'                        , 'add current'],
       " \ 'S' : [':!git status'                      , 'status'],
-" 
-" 
-" 
 
 let g:which_key_map.G = {
       \ 'name' : '+gist' ,
@@ -268,29 +266,32 @@ let g:which_key_map.G = {
 " l is for language server protocol
 let g:which_key_map.l = {
       \ 'name' : '+lsp' ,
-      \ 'a' : [':Lspsaga code_action'                , 'code action'],
+      \ 'a' : [':Lspsaga code_action'                , 'quickfix'],
       \ 'A' : [':Lspsaga range_code_action'          , 'selected action'],
-      \ 'd' : [':LspDefinition'                      , 'definition'],
-      \ 'D' : [':LspDeclaration'                     , 'workspace_diagnostics'],
+      \ 'd' : [':Telescope lsp_document_diagnostics' , 'document diagnostics'],
+      \ 'D' : [':Telescope lsp_workspace_diagnostics', 'workspace diagnostics'],
       \ 'f' : [':LspFormatting'                      , 'format'],
-      \ 'h' : [':Lspsaga hover_doc'                  , 'hover_doc'],
       \ 'H' : [':Lspsaga signature_help'             , 'signature_help'],
-      \ 'K' : [':LspHover'                           , 'hover'],
-      \ 'i' : [':LspImplementation'                  , 'lsp_info'],
       \ 'I' : [':LspInfo'                            , 'lsp_info'],
       \ 'l' : [':Lspsaga lsp_finder'                 , 'lsp_finder'],
       \ 'L' : [':Lspsaga show_line_diagnostics'      , 'line_diagnostics'],
-      \ 'n' : [':Lspsaga diagnostic_jump_next'       , 'next_diagnostic'],
       \ 'o' : [':Vista!!'                            , 'outline'],
-      \ 'p' : [':Lspsaga diagnostic_jump_prev'       , 'prev diagnostic'],
-      \ 'q' : [':Lspsaga code_action'                , 'quickfix'],
-      \ 'r' : [':LspReferences'                      , 'references'],
-      \ 'R' : [':LspRename'                          , 'rename'],
+      \ 'p' : [':Lspsaga preview_definition'         , 'preview definition'],
+      \ 'q' : [':Telescope quickfix'                 , 'quickfix'],
+      \ 'r' : [':LspRename'                          , 'rename'],
       \ 'T' : [':LspTypeDefinition'                  , 'type defintion'],
       \ 'x' : [':cclose'                             , 'close quickfix'],
-      \ 'y' : [':LspDocumentSymbol'                  , 'document symbols'],
-      \ 'Y' : [':LspWorkspaceSymbol'                 , 'workspace symbols'],
+      \ 's' : [':Telescope lsp_document_symbols'     , 'document symbols'],
+      \ 'S' : [':Telescope lsp_workspace_symbols'    , 'workspace symbols'],
       \ }
+      " \ 'D' : [':LspDeclaration'                     , 'workspace_diagnostics'],
+      " \ 'r' : [':Telescope lsp_references'           , 'references'],
+      " \ 'p' : [':Lspsaga diagnostic_jump_prev'       , 'prev diagnostic'],
+      " \ 'n' : [':Lspsaga diagnostic_jump_next'       , 'next_diagnostic'],
+      " \ 'q' : [':Lspsaga code_action'                , 'quickfix'],
+      " \ 'i' : [':LspImplementation'                  , 'lsp_info'],
+      " \ 'h' : [':Lspsaga hover_doc'                  , 'hover_doc'],
+      " \ 'K' : [':LspHover'                           , 'hover'],
 
 " t is for terminal
 let g:which_key_map.t = {
@@ -309,52 +310,4 @@ let g:which_key_map.t = {
       \ 'u' : [':FloatermNew ncdu'                              , 'ncdu'],
       \ }
 
-" w is for wiki
-" let g:which_key_map.w = {
-"       \ 'name' : '+wiki' ,
-"       \ 'w' : ['<Plug>VimwikiIndex'                              , 'ncdu'],
-"       \ 'n' : ['<plug>(wiki-open)'                              , 'ncdu'],
-"       \ 'j' : ['<plug>(wiki-journal)'                              , 'ncdu'],
-"       \ 'R' : ['<plug>(wiki-reload)'                              , 'ncdu'],
-"       \ 'c' : ['<plug>(wiki-code-run)'                              , 'ncdu'],
-"       \ 'b' : ['<plug>(wiki-graph-find-backlinks)'                              , 'ncdu'],
-"       \ 'g' : ['<plug>(wiki-graph-in)'                              , 'ncdu'],
-"       \ 'G' : ['<plug>(wiki-graph-out)'                              , 'ncdu'],
-"       \ 'l' : ['<plug>(wiki-link-toggle)'                              , 'ncdu'],
-"       \ 'd' : ['<plug>(wiki-page-delete)'                              , 'ncdu'],
-"       \ 'r' : ['<plug>(wiki-page-rename)'                              , 'ncdu'],
-"       \ 't' : ['<plug>(wiki-page-toc)'                              , 'ncdu'],
-"       \ 'T' : ['<plug>(wiki-page-toc-local)'                              , 'ncdu'],
-"       \ 'e' : ['<plug>(wiki-export)'                              , 'ncdu'],
-"       \ 'u' : ['<plug>(wiki-list-uniq)'                              , 'ncdu'],
-"       \ 'U' : ['<plug>(wiki-list-uniq-local)'                              , 'ncdu'],
-"       \ }
-
-" Global
-" <Plug>VimwikiIndex
-" <Plug>VimwikiTabIndex
-" <Plug>VimwikiUISelect
-" <Plug>VimwikiDiaryIndex
-" <Plug>VimwikiMakeDiaryNote
-" <Plug>VimwikiTabMakeDiaryNote
-" <Plug>VimwikiMakeYesterdayDiaryNote
-" <Plug>VimwikiMakeTomorrowDiaryNote
-"
-" " Local
-" <Plug>Vimwiki2HTML
-" <Plug>Vimwiki2HTMLBrowse
-" <Plug>VimwikiDiaryGenerateLinks
-" <Plug>VimwikiFollowLink
-" <Plug>VimwikiSplitLink
-" <Plug>VimwikiVSplitLink
-" <Plug>VimwikiTabnewLink
-" <Plug>VimwikiGoBackLink
-" <Plug>VimwikiNextLink
-" <Plug>VimwikiPrevLink
-" <Plug>VimwikiGoto
-" <Plug>VimwikiDeleteLink
-" <Plug>VimwikiRenameLink
-" <Plug>VimwikiAddHeaderLevel
-
-" Register which key map
 call which_key#register('<Space>', "g:which_key_map")

+ 64 - 67
lua/plugins/telescope-config.lua

@@ -1,76 +1,73 @@
 local actions = require('telescope.actions')
 -- Global remapping
 ------------------------------
-      -- '--color=never',
-require('telescope').setup{
-  defaults = {
-    vimgrep_arguments = {
-      'rg',
-      '--no-heading',
-      '--with-filename',
-      '--line-number',
-      '--column',
-      '--smart-case'
-    },
-    prompt_position = "bottom",
-    prompt_prefix = " ",
-    selection_caret = " ",
-    entry_prefix = "  ",
-    initial_mode = "insert",
-    selection_strategy = "reset",
-    sorting_strategy = "descending",
-    layout_strategy = "horizontal",
-    layout_defaults = {
-      horizontal = {
-        mirror = false,
-      },
-      vertical = {
-        mirror = false,
-      },
-    },
-    file_sorter =  require'telescope.sorters'.get_fuzzy_file,
-    file_ignore_patterns = {},
-    generic_sorter =  require'telescope.sorters'.get_generic_fuzzy_sorter,
-    shorten_path = true,
-    winblend = 0,
-    width = 0.75,
-    preview_cutoff = 120,
-    results_height = 1,
-    results_width = 0.8,
-    border = {},
-    borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' },
-    color_devicons = true,
-    use_less = true,
-    set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil,
-    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,
+-- '--color=never',
+require('telescope').load_extension('media_files')
+require('telescope').setup {
+    defaults = {
+        vimgrep_arguments = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'},
+        prompt_position = "top",
+        prompt_prefix = " ",
+        selection_caret = " ",
+        entry_prefix = "  ",
+        initial_mode = "insert",
+        selection_strategy = "reset",
+        sorting_strategy = "descending",
+        layout_strategy = "horizontal",
+        layout_defaults = {horizontal = {mirror = false}, vertical = {mirror = false}},
+        file_sorter = require'telescope.sorters'.get_fuzzy_file,
+        file_ignore_patterns = {},
+        generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
+        shorten_path = true,
+        winblend = 0,
+        width = 0.75,
+        preview_cutoff = 120,
+        results_height = 1,
+        results_width = 0.8,
+        border = {},
+        borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'},
+        color_devicons = true,
+        use_less = true,
+        set_env = {['COLORTERM'] = 'truecolor'}, -- default = nil,
+        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,
 
-    -- Developer configurations: Not meant for general override
-    buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker,
-    mappings = {
-      i = {
-      ["<C-j>"] = actions.move_selection_next,
-      ["<C-k>"] = actions.move_selection_previous,
-        -- To disable a keymap, put [map] = false
-        -- So, to not map "<C-n>", just put
-        -- ["<c-x>"] = false,
+        -- Developer configurations: Not meant for general override
+        buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker,
+        mappings = {
+            i = {
+                ["<C-j>"] = actions.move_selection_next,
+                ["<C-k>"] = actions.move_selection_previous,
+                -- To disable a keymap, put [map] = false
+                -- So, to not map "<C-n>", just put
+                -- ["<c-x>"] = false,
 
-        -- Otherwise, just set the mapping to the function that you want it to be.
-        -- ["<C-i>"] = actions.select_horizontal,
+                -- Otherwise, just set the mapping to the function that you want it to be.
+                -- ["<C-i>"] = actions.select_horizontal,
 
-        -- Add up multiple actions
-        ["<CR>"] = actions.select_default + actions.center,
+                -- Add up multiple actions
+                ["<CR>"] = actions.select_default + actions.center
 
-        -- You can perform as many actions in a row as you like
-        -- ["<CR>"] = actions.select_default + actions.center + my_cool_custom_action,
-      },
-      n = {
-      ["<C-j>"] = actions.move_selection_next,
-      ["<C-k>"] = actions.move_selection_previous,
-        -- ["<esc>"] = actions.close,
-        -- ["<C-i>"] = my_cool_custom_action,
-      },
+                -- You can perform as many actions in a row as you like
+                -- ["<CR>"] = actions.select_default + actions.center + my_cool_custom_action,
+            },
+            n = {
+                ["<C-j>"] = actions.move_selection_next,
+                ["<C-k>"] = actions.move_selection_previous
+                -- ["<esc>"] = actions.close,
+                -- ["<C-i>"] = my_cool_custom_action,
+            }
+        }
     },
-  }
+    require'telescope'.setup {
+        extensions = {
+            media_files = {
+                -- filetypes whitelist
+                -- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
+                filetypes = {"png", "webp", "jpg", "jpeg"},
+                find_cmd = "rg" -- find command (defaults to `fd`)
+            }
+        }
+    }
 }

+ 7 - 3
plug-config/lsp-config.vim

@@ -3,10 +3,14 @@ nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
 nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>
 nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
 nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
-nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
+nnoremap <silent> ca :Lspsaga code_action<CR>
+" nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
+nnoremap <silent> K :Lspsaga hover_doc<CR>
 nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
-nnoremap <silent> <C-p> <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
-nnoremap <silent> <C-n> <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
+" nnoremap <silent> <C-p> <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
+" nnoremap <silent> <C-n> <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
+nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>
+nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>
 " autoformat
 autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)
 autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100)

+ 1 - 1
plug-config/rnvimr.vim

@@ -1,5 +1,5 @@
 " Make Ranger replace netrw and be the file explorer
-" let g:rnvimr_ex_enable = 1
+let g:rnvimr_ex_enable = 1
 
 let g:rnvimr_draw_border = 1
 

+ 4 - 0
vim-plug/plugins.vim

@@ -70,6 +70,7 @@ call plug#begin('~/.config/nvim/autoload/plugged')
     Plug 'nvim-lua/popup.nvim'
     Plug 'nvim-lua/plenary.nvim'
     Plug 'nvim-telescope/telescope.nvim'
+    Plug 'nvim-telescope/telescope-media-files.nvim'
     " Intellisense
     Plug 'neovim/nvim-lspconfig'
     Plug 'hrsh7th/nvim-compe'
@@ -78,6 +79,7 @@ call plug#begin('~/.config/nvim/autoload/plugged')
     Plug 'kosayoda/nvim-lightbulb'
     Plug 'mfussenegger/nvim-jdtls'
     Plug 'mfussenegger/nvim-dap'
+    " https://github.com/mhartington/formatter.nvim look into this
     " File Explorer
     Plug 'kyazdani42/nvim-tree.lua'
     " Themes
@@ -104,6 +106,8 @@ call plug#begin('~/.config/nvim/autoload/plugged')
     Plug 'norcalli/nvim-colorizer.lua'
     " live server
     Plug 'turbio/bracey.vim'
+    " Better quickfix
+    Plug 'kevinhwang91/nvim-bqf'
   endif
 
 call plug#end()