imxiejie / ThinkVim

Vim configuration in the 21st century
MIT License
868 stars 106 forks source link

[Feature Request] Enhance the keymappings and colorscheme config #105

Closed 20jam closed 4 years ago

20jam commented 4 years ago

Hay, I’d like to know if there is a way I can wave reset all keymaps for the plugins such as clep. The reason for that is I already have my on mappings for all the plugins in thinkvim.

Regards

glepnir commented 4 years ago

@20jam Thanks report. First i want to know does you want to flow my branch or you build yourself config based on thinkvim? Replace the file in the keybinds folder with your keybinds file.By the way I can add a setting to disable thinkvim's default keybindings. But users need to configure the keybinding of each plugin by themselves, which is very complicated and cumbersome. Because thinkvim has more than 50 default plugins.

20jam commented 4 years ago

Hay, thank you for all the stuff your doing 🙏.

I’d prefer to follow your branch, your doing a great job maintaining it. I forked thinkvim months ago, and since then I created my own mappings for plugin and for controlling nvim aspects such as navigation, as well as other tweaks.

I revisited thinkvim branch and found how awesome it is becoming, plus my fork is so messy. However, there are 5 issues prohibiting me from doing so:

1) disabling current mappings for plugins and other, 2) disable current theme setup and have my auto integration of base16 + zsh setup, 3) disable plugins (OK), 4) change plugins settings (OK), 5) change leader keys (OK) .

For the 50+ plugins, users can have an example file where they can edit themselves or keep it as default. If you want my suggestion, its better to have all mappings in .thinkvim.d, available after installation. As you know mappings is very sensitive matter for vim users. I think this approach will make thinkvim shine. All others have default mappings that is so tricky to change, and that a primary reason why I left them.

The other suggestion I have is base16 theme and automatically update nvim color-shame based on zsh base16. If you want I can share with you the vimscript and shellscript to get this working. (refer to my fork)

glepnir commented 4 years ago

@20jam Nice to discuss with you, the previous thinkvim is messy, so I adjusted it, I hope this configuration is lightweight and every plugin user will use it frequently. About your 5 issues.

  1. This is achievable by adding an option eg g:thinkvim_disable_pluginsmap to disable all plugins config.Or an option to disable the key of a plugin g:thinkvim_disable_pluginmap.The problem with disabling all plugins keybinds is that the configuration of whichkey will be troublesome for users, I prefer to disable the key of a certain plugin. This way users do not have to spend time adjusting all plugins keybinds.
  2. it's very easy to add colorscheme plugin. you just add it to your plugins.yaml file
    - { repo: chriskempson/base16-vim }

    By the way , I used to like this theme, and I will add it to the colors folder for the next update.

      1. we already support.
20jam commented 4 years ago

I just update the base16 setup , you can see it here https://github.com/20jam/vim on last commit .

20jam commented 4 years ago

What do you think of having all mappings and plugins mappings in .thinkvim.d instead ?.

For whichkey, I think 🤔 it isn’t that great, it has issues and is not reliable, plus all the manual work it needs . I think you should drop it. This the first plugin to disable lol

Thank you

glepnir commented 4 years ago

@20jam Thanks for your share. it looks like nice. PR welcome. Mapping is sensitive to users, because everyone has their own habits, so I think it is necessary to enhance the configuration of the mapping. I will add 2 options to disable the key configuration of all plugins and individual plugins. I will update any progress here. whichkey may be useful for some new vimmers,Maybe I will find a good way to combine them.

glepnir commented 4 years ago

I think I already have ideas, I will try to implement it recently, and test.

20jam commented 4 years ago

Great looking forward to chat with to contribute more to the project. Thanks 🙏

glepnir commented 4 years ago

@20jam I will report any new progress here, I hope you will like the new progress, there is no need to close this issue, because we need to resolve it

20jam commented 4 years ago

There is a need to have plugin: wincent/pinnacle and the following codesnipt in autoload to get the base16 setup working

function! etc#active() "(((
  " "Needed for base16 Setup"
  try
    call pinnacle#highlight({})
    return 1
  catch /E117/
    " Pinnacle probably isn't loaded
    return 0
  endtry
endfunction
" ))) 
glepnir commented 4 years ago

@20jam Please check the keybinds branch, I had implement it.There has two useful options

" disable all keymaps of plugins
let g:thinkvim_disable_mappings = 0
" disable some plugins keymap
let g:thinkvim_disable_pmaping = []

If set the thinkvim_disable_mappings to 1 will disable all plugins keybinds. The thinkvim_disable_pmaping is a list ,you can add the plugins name in it. Thinkvim will does not load this plugin's keybinds. this is the plugins list that you can add to this option.

dein.vim vim-buffet markdown-preview.nvim
indentLine any-jump.vim vim-floaterm
vim-dadbod-ui dash.vim coc-clap
coc.nvim vim-clap vim-go vim-delve
vimagit vim-choosewin caw.vim vim-smoothie
goyo.vim defx.nvim vim-quickrun vim-easymotion
vim-smartchr iron.nvim vim-sandwich vim-startify
vim-fugitive vim-mundo vista.vim
20jam commented 4 years ago

Great work, I liked how we can choose what plugin mapping to disable.m, what about the general mappings, such as mapping to control buffers or open file manager?

glepnir commented 4 years ago

@20jam We can create a keybinds.vim then load it after general mappings. file manager is plugins keymap on defx or coc-explorer. control buffers? the leader + b is not pretty? ,Also the buffer keybinds on vim-buffet plugin.

20jam commented 4 years ago

@glepnir Leader + b is great, For example, I like leader + e to open file tree its so logical as I have super+e to open ranger. However, remember your trying to have an option to disable everything so the user can add there own mappings if existing or copy the default from thinkvim and customize it in .thinkvim.d . This way we can be sure that new mappings won’t conflict with default.

glepnir commented 4 years ago

@20jam Hmm ,Sorry, I don’t understand what you mean. For example, defx.nvim is a file tree plugin, and its default is leader + e. If users do n’t like this key setting, you can add it to let g:thinkvim_disable_pmaping = ['defx.nvim'] then custom your keymap on .thinkvim.d/plugins.yaml like nnoremap <silent> <leader>E :Defx.

Maybe provide a reference file for the key. Then the user open it by leader + o e for reference. Or write it on wiki or docs?

20jam commented 4 years ago

I mean that as the user can disable plugins mappings, he can as well disable other mappings created by thinkvim.

Then, an available example files in .thinkvim.d or docs will be helpful for user.

Similarly we can have mapping files (both plugins and general) located in .thinkvim.d by default. This is a simpler way. User can keep them as is or edit them.

glepnir commented 4 years ago

@20jam Ok i know,To exclude the mapping of plugins, I provide some other key mapping, if the user needs to disable them, they may need to be classified. I think the most easy way is generate the keybinds.vim to .thinkvimd.d folder. thinkvim doesn't provide any keybinds.

20jam commented 4 years ago

Yes exactly, I’d suggest to have two files generated. One for general mappings that isn’t related to any plugin called keybinds.vim, and the other called plugins.vim for plugins mappings. The point here is two separate plugin mappings from general ones.

glepnir commented 4 years ago

Here are a solutions, 1. Similar to thinkvim's language selection function, we can provide options when executing the installation script, using the default key and custom key. The default keybinds is the current keybinds. Users can use these 2 options to disable the key position and the key position of individual plugins. The custom key is to generate the key to the .thinkvim.d folder. Thinkvim load the key file of this folder without loading the default.

glepnir commented 4 years ago

@glepnir I classified the key mapping.this is now list that can add to option

plugins:
dein.vim vim-buffet markdown-preview.nvim
indentLine any-jump.vim vim-floaterm
vim-dadbod-ui dash.vim coc-clap
coc.nvim vim-clap vim-go vim-delve
vimagit vim-choosewin caw.vim vim-smoothie
goyo.vim defx.nvim vim-quickrun vim-easymotion
vim-smartchr iron.nvim vim-sandwich vim-startify
vim-fugitive vim-mundo vista.vim

general:
insert command quiet window session toggle normal

check this commit https://github.com/hardcoreplayers/ThinkVim/commit/3d17bafa8f80061053955be2b2bceea0bfa422a8

glepnir commented 4 years ago

Now we need to discuss about the second issue.

20jam commented 4 years ago

Okay, As soon as I test the current changes, we will discuss the other issue feature. Primarily, it has the following aspects :

  1. adding vim-base16 setup to thinkvim as a module.
  2. echoing zsh-base16 config to .zshrc during installation, and
  3. editing setup colors for status bar and popup for clap and others to be constant with the choosing theme
20jam commented 4 years ago

Ok I cloned the last commit, what do I do know to disable plugin mappings and general mappings ?

20jam commented 4 years ago

Okay let g:thinkvim_disable_mappings = 1 disabled all mappings successfully, However, Whichkey is still working, I guess I need to disabled it manually from my .thinkvim.d/init.vim .

PS: I found some issues with clep such as sometimes the the rounded corners get stuck on the screen after opening, I will open issues and feature request after we're done here .

glepnir commented 4 years ago

@20jam I add a patch to control whichkey . you can disable it on plugins.yaml use if:0,if disable it, dosen't load any whichkey replacement.

glepnir commented 4 years ago

what do I do know to disable plugin mappings and general mappings ?

Ok we should create a doc .

glepnir commented 4 years ago
  1. adding vim-base16 setup to thinkvim as a module.
  2. echoing zsh-base16 config to .zshrc during installation, and.

About vim-base16 and zsh ,I need to check it when i have time. the fast way is create a pr.

  1. editing setup colors for status bar and popup for clap and others to be constant with the choosing theme

Now we have an option,the default value is 1. 0 means dosen't load the thinkvim custom color.

" Load thinkvim provide color config
let g:thinkvim_load_color = 1

I think you mean the colorscheme of spaceline ? easy to add colorscehme spaceline.I will add more colorscheme, currently I am missing some design ideas.

glepnir commented 4 years ago

This pr will enhance the install script to install colorschme plugins.https://github.com/hardcoreplayers/ThinkVim/pull/108. next add the base16 zsh config .need to check how it works.

20jam commented 4 years ago

Hay, here is my input and thoughts to recent changes:

1) The ability to disable default mappings is amazing, thank you very much for this added feature. However, After disabling mappings my new mappings won’t work properly because of whichkey, only after disabling it it worked. I suggest, if it ware possible to make the plugins mappings disabling function disable whichkey or whichkey settings as well. 2) Wait, how to disable other mappings as well such as insert? 3) choosing colors during installation may prove to be beneficial, but I don’t know if its a approbate. Can you explain the logic of the choosing color script. 4) After choosing base16c the colors won’t work as expected, there is an option mentioned in base16 vim github repo related to termcolors. I suggest having a module for base16 where we can have the settings as well as the script the reads the color option set by zsh located .thinkvim.d/.theme

4) I’m new to PR and stuff , after I have my machine ready I’ll free sometime to get to know strategies and tactics I can contribute through

PS: I’m sorry I haven’t replied sooner, I’m currently reconfiguring and reinstating my main machine. Hopefully, I’m going to be done soon. Also is there a way to talk to directlyz thinks

20jam commented 4 years ago

Another thing, The spaceline, its honestly outdated. A minimalist alternative would be much appreciate. With a look closer to buffer tabs with squared edges.

20jam commented 4 years ago
" Load thinkvim provide color config
let g:thinkvim_load_color = 1

Very useful, If it going to disable any color configuration, I think the installation part of the script would be skipped if we’re not going to have a dedicated module for base16 setup.

glepnir commented 4 years ago

@20jam please see the new change, i had remove color.vim. because the i made a new colorscheme called oceanic_material image

20jam commented 4 years ago

Okay, this new colorscheme is a new color option you develop and we want me to review right ?

glepnir commented 4 years ago

spaceline I had update it. eg. add the diff icon. About colorscheme, i think everyone has their own like.so thinkvim shouldn't config it. it depends on user. If you have good suggestions or ideas on this colorscheme, you can discuss with me in the issue under this colorscheme repo.

glepnir commented 4 years ago

@20jam About keymap , now we have a variable to control whichkey replacements.like startify plugin

function! s:load_startify() abort
  if dein#tap('vim-startify')
    nnoremap <silent> <Leader>os  :<C-u>Startify<CR>
    if s:enable_whichkey
      let g:which_key_map.o.s = 'open stratify'
    endif
  endif
endfunction

If you don't disable whichkey on .thinkvimd.d/plugins.yaml, it wil show replacements. maybe it will cause your custom keymap failed.

20jam commented 4 years ago

Yes, true. Sometime users my require multiple of theme.

About colorschemes, lol I’ve bad with colors and creating great colorschems.

I think 🤔 my most challenging aspect of colors is having them consistent with spaceline, buffer tab and clap popup.

20jam commented 4 years ago

I will create a file of all the keyboard maps done in thinkVim to make it as a point of reference if users choice to disable them.

glepnir commented 4 years ago

@20jam Ok, now you can add every colorscheme you like on .thinkvim.d/plugins.yaml then leader+ p r to clear cache to load new plugins. and leader + tc to select it. about keymap . We can patch it.

if s:enable_whichkey || !g:thinkvim_disable_mappings
      let g:which_key_map.o.s = 'open stratify'
endif

then if you set the g:thinkvim_disable_mappings to 1 , thinkvim will doesn't load the whichkey replacement.

glepnir commented 4 years ago

Please update the latest thinkvim develop branch.then test it . If the keymap also cant't work ,add this patch then test.

if s:enable_whichkey || !g:thinkvim_disable_mappings
      let g:which_key_map.o.s = 'open stratify'
endif
20jam commented 4 years ago

Okay, as soon as I tested , I’ll report back. Thanks 🙏

20jam commented 4 years ago

Okay, so after cloning the last commit, I had this errors:

Undefined variable: s:enable_whichkey Invalid expression s:enable_whichkey || !g:thinkvim_disable_mappings

20jam commented 4 years ago

Also my mappings still won’t work even after disabling whichkey. last time I got it working by manually commenting whichkey configurations

20jam commented 4 years ago

An irrelevant question: how do I add my own autoload functions.

glepnir commented 4 years ago

@20jam autoload functions? The autoload folder means that this folder will be loaded when vim is started. You can define and call it in init.vim, and their effects are the same. The autoload folder of vim is different from the autoload of emacs. Wha options do you used. thinkvim_disable_mappings?We should add an option to determine whether the user enabled whichkey?

20jam commented 4 years ago

I used thinkvim_disable_mappings, it should definitively disable whichkey configuration. Every-time a press on space it gives me the preconfigured menu. And my keys won't work, instead it output annoying message by which key

Can you give a code snippet to make a folder called autoload in .thinkvim.d thanks :D ?

glepnir commented 4 years ago

I want to know why you need autoload? The user's init.vim should not be very long, because thinkvim does most of the things. Is there any difference between the function you defined in autoload and the function you defined and called in init.vim?thinkvim provides a source function, you can split the file and then load the file through this source function

20jam commented 4 years ago

Yes, thats true. I want to define a global function. s: ... it’s okay if its not possible.

glepnir commented 4 years ago

@20jam s:funcname not a global function..

20jam commented 4 years ago

Oh I see, I defined some functions in my old autoload, is it possible then to declare and use them and if it is how. Again this question relates to my functions under my old autoload/etc#

glepnir commented 4 years ago

There has a function called utils#source_file, has two args that first is $THINKVIM, second it's filename which on .thinkvim.d folder, if you want split your init.vim this function will be useful.