Chris 4 năm trước cách đây
mục cha
commit
be6c6ca92f

+ 3 - 5
README.md

@@ -43,16 +43,13 @@ $HOME/.config/nvim/lua/nv-vscode/init.vim
 ## TODO
 
 **HIGH PRIORITY**
-- snippet support
-- react commenting
-- toggle virtual text diagnostics
-- improve VSCode support
 - formatting using efm server for python
 - formatting using efm server for prettier/eslint
+- wrap all whichkey lsp in functions
+- snippet support
 
 **LOW PRIORITY**
 - redo barbar highlight groups
-- wrap all whichkey lsp in functions
 - make java code actions prettier
 - figure out how to format java
 - setup junit tests for java
@@ -67,3 +64,4 @@ $HOME/.config/nvim/lua/nv-vscode/init.vim
 - look into autoinstall lsp
 - get logo
 - configure neogit
+- toggle virtual text diagnostics

+ 2 - 0
ftplugin/javascriptreact.vim

@@ -0,0 +1,2 @@
+setlocal commentstring={/*%s*/}
+

+ 5 - 4
init.lua

@@ -1,11 +1,13 @@
 if vim.g.vscode then
   vim.cmd('source ~/.config/nvim/vimscript/nv-vscode/init.vim')
+  require('settings')
 else
   -- General mappings
   require('plugins')
   require('keymappings')
   require('settings')
   require('colorscheme')
+  require('utils')
 
   -- Plugins
   require('nv-compe')
@@ -14,11 +16,11 @@ else
   require('nv-treesitter')
   require('nv-galaxyline')
   require('nv-barbar')
+  require('nv-quickscope')
   require('nv-gitsigns')
   require('nv-nvim-autopairs')
   require('nv-neogit')
-  require('nv-kommentary')
-  require('nv-quickscope')
+  require('nv-comment')
   require('nv-rnvimr')
   require('nv-startify')
   require('nv-telescope')
@@ -42,6 +44,5 @@ else
   require('lsp.python-ls')
   require('lsp.json-ls')
   require('lsp.yaml-ls')
-  require('utils')
-  vim.cmd([[autocmd BufRead * lua print("hi")]])
 end
+

+ 3 - 0
lua/nv-comment/init.lua

@@ -0,0 +1,3 @@
+require('nvim_comment').setup()
+vim.api.nvim_set_keymap("n", "<leader>/", ":CommentToggle<CR>", {noremap=true, silent = true})
+vim.api.nvim_set_keymap("v", "<leader>/", ":CommentToggle<CR>", {noremap=true, silent = true})

+ 0 - 60
lua/nv-kommentary/init.lua

@@ -1,60 +0,0 @@
--- vim.api.nvim_set_keymap("v", "<leader>/", "<Plug>kommentary_visual_default", {})
-
--- require('kommentary.config').configure_language("default", {
---     prefer_single_line_comments = true,
--- })
-
--- require('kommentary.config').configure_language("python", {
---     prefer_single_line_comments = true,
--- })
-
--- require('kommentary.config').configure_language("javascriptreact", {
---     prefer_multi_line_comments = true,
---     -- single_line_comment_string = "{/*\\ %s\\ */}",
---     multi_line_comment_strings = {"{/*", "*/}"},
--- })
-
---[[ This is our custom function for toggling comments with a custom commentstring,
-it's based on the default toggle_comment, but before calling the function for
-toggling ranges, it sets the commenstring to something else. After it is done,
-it sets it back to what it was before. ]]
--- function toggle_comment_custom_commentstring(...)
---     local args = {...}
---     -- Save the current value of commentstring so we can restore it later
---     local commentstring = vim.bo.commentstring
---     -- Set the commentstring for the current buffer to something new
---     vim.bo.commentstring =  "{/*%s*/}"
---     -- print(args[1])
---     -- print(args[2])
---     -- print(vim.inspect(args[1]))
---     print(vim.inspect(args))
-
---     --[[ Call the function for toggling comments, which will resolve the config
---     to the new commentstring and proceed with that. ]]
---     require('kommentary.kommentary').toggle_comment_range(args[1], args[2],
---         require('kommentary.config').get_modes().normal)
---     -- Restore the original value of commentstring
---     vim.api.nvim_buf_set_option(0, "commentstring", commentstring)
--- end
-
---     -- vim.bo.commentstring =  "{/*%s*/}"
--- -- Set the extra mapping for toggling a single line in normal mode
--- vim.api.nvim_set_keymap('n', '<leader>/',
--- '<cmd>lua require("kommentary");kommentary.go(' .. require('kommentary.config').context.line .. ', '
--- .. "'toggle_comment_custom_commentstring'" .. ')<cr>',
--- { noremap = true, silent = true })
--- -- -- Set the extra mapping for toggling a range with a motion
--- -- vim.api.nvim_set_keymap('n', '<leader>/',
--- -- 'v:lua.kommentary.go(' .. require('kommentary.config').context.init .. ', ' ..
--- -- "'toggle_comment_custom_commentstring'" .. ')',
--- -- { noremap = true, expr = true })
--- -- -- Set the extra mapping for toggling a range with a visual selection
--- -- vim.api.nvim_set_keymap('v', 'gC',
--- -- '<cmd>lua require("kommentary");kommentary.go(' .. require('kommentary.config').context.visual .. ', '
--- -- .. "'toggle_comment_custom_commentstring'" .. ')<cr>',
--- -- { noremap = true, silent = true })
-
-require('nvim_comment').setup()
-
-
---vim.api.nvim_buf_set_option(0, "commentstring", "{/*%s*/}")

+ 1 - 0
lua/plugins.lua

@@ -117,4 +117,5 @@ return require('packer').startup(function()
   --use 'suy/vim-context-commentstring'
   -- use 'b3nj5m1n/kommentary'
   use 'andymass/vim-matchup'
+  use 'sheerun/vim-polyglot'
 end)

+ 0 - 6
lua/utils.lua

@@ -26,14 +26,8 @@ define_augroups(
             {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
             {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
             {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
-
             {'FileType', 'java', 'luafile ~/.config/nvim/lua/lsp/java-ls.lua'},
             {'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'},
-            {'FileType', 'lua', 'lua print("hi")'},
-            --{'BufRead', '*', 'lua vim.api.nvim_buf_set_option(0, "commentstring", "{/*%s*/}")'},
-            --{'BufNewFile', '*', 'lua vim.api.nvim_buf_set_option(0, "commentstring", "{/*%s*/}")'},
-            {'BufNewFile', '*', 'verbose setlocal commentstring="{/*%s*/}"'},
-            {'BufRead', '*', 'verbose setlocal commentstring="{/*%s*/}"'},
 
         },
     }

+ 1 - 0
utils/installer/install-nv-code.sh

@@ -58,6 +58,7 @@ installpynvim() { \
 cloneconfig() { \
   echo "Cloning NVCode configuration"
   git clone https://github.com/ChristianChiarulli/nvcode.git ~/.config/nvcode
+  nvim --headless +PackSync +qall > /dev/null 2>&1
 }
 
 asktoinstallnode() { \

+ 2 - 2
vimscript/nv-commentary/init.vim

@@ -6,6 +6,6 @@ function! Comment()
   endif
  endfunction
 vnoremap <silent> <space>/ :call Comment()
-"autocmd! BufRead,BufNewFile *.{jsx,jx,js} setlocal filetype=javascript.jsx
-autocmd FileType javascriptreact setlocal commentstring={/*\ %s\ */}
+autocmd! BufRead,BufNewFile *.{jsx,jx,js} setlocal filetype=javascript
+"autocmd FileType javascriptreact setlocal commentstring={/*\ %s\ */}
 

+ 2 - 2
vimscript/nv-whichkey/init.vim

@@ -26,8 +26,8 @@ autocmd  FileType which_key set laststatus=0 noshowmode noruler
 " let g:which_key_map['/'] = [ ':call Comment()'                                 , 'comment' ]
 " let g:which_key_map['/'] = { 'name' : 'comment' }
 
-let g:which_key_map['/'] = [ ':call Comment()'                                 , 'comment' ]
-"let g:which_key_map['/'] = 'which_key_ignore'
+"let g:which_key_map['/'] = [ ':call Comment()'                                 , 'comment' ]
+let g:which_key_map['/'] = 'which_key_ignore'
 let g:which_key_map['?'] = [ ':NvimTreeFindFile'                               , 'find current file' ]
 let g:which_key_map['e'] = [ ':NvimTreeToggle'                                 , 'explorer' ]
 let g:which_key_map['f'] = [ ':Telescope find_files'                           , 'find files' ]