├── init.lua ├── lua └── wind │ ├── plug │ ├── lsp │ │ ├── lang │ │ │ ├── dart.lua │ │ │ ├── emmetls.lua │ │ │ ├── tsserver.lua │ │ │ ├── tailwind.lua │ │ │ ├── angular.lua │ │ │ ├── booster.lua │ │ │ ├── eslint.lua │ │ │ ├── mlua.lua │ │ │ ├── efm.lua │ │ │ └── svelte.lua │ │ ├── setup.lua │ │ ├── functions.lua │ │ └── lsp.lua │ ├── lsp-trouble.lua │ ├── me │ │ ├── init.lua │ │ └── alternate.lua │ ├── oscyank.lua │ ├── project-config.lua │ ├── spectre.lua │ ├── matchup.lua │ ├── lspsaga.lua │ ├── _end.lua │ ├── eft.lua │ ├── indent-blankline.lua │ ├── web-devicons.lua │ ├── formatter.lua │ ├── autopairs.lua │ ├── treesitter.lua │ ├── windline │ │ ├── animation.lua │ │ ├── init.lua │ │ └── comps.lua │ ├── gitsigns.lua │ ├── compe.lua │ ├── _start.lua │ ├── copyq.lua │ ├── which-key.lua │ └── telescope.lua │ ├── general │ ├── themes │ │ ├── wind.lua │ │ ├── miramare.lua │ │ └── gruvbox.lua │ ├── init.lua │ ├── abbre.lua │ ├── autocmd.lua │ ├── keys.lua │ └── setting.lua │ ├── init.lua │ ├── core │ ├── env.lua │ ├── init.lua │ ├── wind.lua │ ├── utils.lua │ ├── plug.lua │ ├── keymap.lua │ └── nav.lua │ └── plugins.lua ├── spell ├── en.utf-8.add └── en.utf-8.add.spl ├── ftplugin ├── gitcommit.vim ├── typescript.vim ├── html.vim ├── lua.lua ├── svelte.vim ├── javascript.vim └── markdown.vim ├── queries └── xml │ ├── injections.scm │ └── highlights.scm ├── .gitignore ├── after └── ftplugin │ ├── image.vim │ └── video.vim ├── scripts ├── agfile.sh └── setup.sh ├── snippets ├── lua.json ├── vim.json ├── global.json ├── html.json ├── markdown.json ├── svelte.json ├── sh.json ├── typescript.json ├── go.json └── dart.json ├── .editorconfig ├── ftdetect └── media.vim ├── local.lua ├── local.sample.lua ├── plug ├── vim-floaterm.vim ├── vim-visual-multi.vim ├── gitopen.vim └── fern.vim ├── note.lua ├── README.md ├── plugin ├── foldtext.vim ├── wind.vim └── key.vim └── autoload └── win.vim /init.lua: -------------------------------------------------------------------------------- 1 | require('wind') 2 | 3 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/dart.lua: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spell/en.utf-8.add: -------------------------------------------------------------------------------- 1 | popup 2 | diff 3 | vim 4 | config 5 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp-trouble.lua: -------------------------------------------------------------------------------- 1 | require("trouble").setup {} 2 | -------------------------------------------------------------------------------- /lua/wind/plug/me/init.lua: -------------------------------------------------------------------------------- 1 | -- some small draft plugin for me 2 | -------------------------------------------------------------------------------- /ftplugin/gitcommit.vim: -------------------------------------------------------------------------------- 1 | setlocal colorcolumn=80 2 | set spell 3 | -------------------------------------------------------------------------------- /queries/xml/injections.scm: -------------------------------------------------------------------------------- 1 | ; injections.scm 2 | ; -------------- 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.local 3 | *.ttf binary 4 | *.png binary 5 | .netrwhist 6 | -------------------------------------------------------------------------------- /ftplugin/typescript.vim: -------------------------------------------------------------------------------- 1 | source $HOME/.config/nvim/ftplugin/javascript.vim 2 | 3 | -------------------------------------------------------------------------------- /spell/en.utf-8.add.spl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windwp/nvim/HEAD/spell/en.utf-8.add.spl -------------------------------------------------------------------------------- /after/ftplugin/image.vim: -------------------------------------------------------------------------------- 1 | call system(wind#open() . ' ' . expand('%:p')) | buffer# | bdelete# 2 | -------------------------------------------------------------------------------- /lua/wind/general/themes/wind.lua: -------------------------------------------------------------------------------- 1 | vim.cmd[[packadd wind-colors]] 2 | vim.cmd[[colorscheme wind]] 3 | -------------------------------------------------------------------------------- /lua/wind/init.lua: -------------------------------------------------------------------------------- 1 | require('wind.core.wind') 2 | import('core') 3 | import('general') 4 | import('plugins') 5 | 6 | -------------------------------------------------------------------------------- /scripts/agfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ ! -z "${@}" ]]; then 3 | ag -g "" | proximity-sort $@ 4 | else 5 | ag -g "" 6 | fi 7 | -------------------------------------------------------------------------------- /after/ftplugin/video.vim: -------------------------------------------------------------------------------- 1 | call system('mpv --geometry=50%+50%+50% ' . shellescape(expand('%:p')) . ' &>/dev/null &') | buffer# | bdelete# 2 | -------------------------------------------------------------------------------- /snippets/lua.json: -------------------------------------------------------------------------------- 1 | { 2 | "foldcomment": { 3 | "prefix": "foldcomment", 4 | "body": "-- $1 {{{\n\t $2 \n-- }}}", 5 | "description": "fold for lua" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /snippets/vim.json: -------------------------------------------------------------------------------- 1 | { 2 | "fold_comment": { 3 | "prefix": "foldcomment", 4 | "body": "\" $1 {{{\n\t $2 \n\" }}}", 5 | "description": "fold for vim" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lua/wind/plug/oscyank.lua: -------------------------------------------------------------------------------- 1 | vim.g.oscyank_term = 'tmux' 2 | vim.cmd[[ 3 | autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '' | OSCYankReg " | endif 4 | ]] 5 | -------------------------------------------------------------------------------- /snippets/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "foldcomment": { 3 | "prefix": "foldcomment", 4 | "body": "-- $1 {{{\n\t $2 \n-- }}}", 5 | "description": "fold for lua" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lua/wind/general/init.lua: -------------------------------------------------------------------------------- 1 | import('general.setting') 2 | -- import('general.statusline') 3 | import('general.keys') 4 | import('general.autocmd').setup() 5 | import('general.abbre') 6 | -------------------------------------------------------------------------------- /lua/wind/general/abbre.lua: -------------------------------------------------------------------------------- 1 | vim.cmd[[ 2 | ab exprot export 3 | ab widht width 4 | ab heigth height 5 | ab resutl result 6 | ab locla local 7 | ab locla local 8 | ab conts const 9 | ]] 10 | -------------------------------------------------------------------------------- /scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git clone https://github.com/savq/paq-nvim.git \ 3 | "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/paqs/opt/paq-nvim 4 | cp ./local.sample.lua ./local.lua 5 | 6 | nvim -c ":PaqInstall" 7 | -------------------------------------------------------------------------------- /lua/wind/plug/project-config.lua: -------------------------------------------------------------------------------- 1 | require('nvim-projectconfig').load_project_config({ 2 | project_dir = "~/.config/projects-config/", 3 | silent = false 4 | }) 5 | 6 | 7 | vim.cmd[[ 8 | autocmd DirChanged * lua require('nvim-projectconfig').load_project_config() 9 | ]] 10 | -------------------------------------------------------------------------------- /snippets/html.json: -------------------------------------------------------------------------------- 1 | { 2 | "ulemmet":{ 3 | "prefix":"ulemmet" , 4 | "body": [ 5 | "" 11 | ] 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | 8 | [*.lua] 9 | indent_style = space 10 | indent_size = 2 11 | 12 | 13 | [*.vim] 14 | indent_style = space 15 | indent_size = 4 16 | 17 | [*.snippets] 18 | indent_style = tab 19 | indent_size = 4 20 | -------------------------------------------------------------------------------- /ftplugin/html.vim: -------------------------------------------------------------------------------- 1 | set foldmethod=manual 2 | nnoremap za zfat 3 | " delete tag in html 4 | nnoremap cx Td2f" 5 | 6 | " augroup remember_folds 7 | " autocmd! 8 | " au BufWinLeave *.html mkview 1 9 | " au BufWinEnter *.html silent! loadview 1 10 | " augroup END 11 | 12 | -------------------------------------------------------------------------------- /ftdetect/media.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.jpg,*.png,*.gif,*.jpeg, set filetype=image 2 | au BufRead,BufNewFile *.mp3,*.flac,*.wav,*.ogg set filetype=audio 3 | au BufRead,BufNewFile *.avi,*.mp4,*.mkv,*.mov,*.mpg set filetype=video 4 | au FileType lua setlocal sw=2 ts=2 sts=2 5 | au FileType vim setlocal sw=2 ts=2 sts=2 6 | -------------------------------------------------------------------------------- /ftplugin/lua.lua: -------------------------------------------------------------------------------- 1 | vim.opt.sw=4 2 | -- it help use gf to move to config on plugins 3 | vim.bo.includeexpr="printf('plug/%s.lua',v:fname)" 4 | vim.bo.suffixesadd=".lua" 5 | 6 | -- it help to press K to go help 7 | vim.bo.keywordprg=":help" 8 | 9 | -- mapping in vim is so ez : 10 | vim.cmd[[ 11 | inoremap ! ~ 12 | ]] 13 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/setup.lua: -------------------------------------------------------------------------------- 1 | local nvim_lsp = require('lspconfig') 2 | 3 | local mlsp = Wind.load_plug("lsp/lsp") 4 | 5 | Wind.load_plug('lsp/functions') 6 | mlsp.lsp_setup(nvim_lsp.yamlls) 7 | mlsp.lsp_setup(nvim_lsp.jsonls) 8 | mlsp.lsp_setup(nvim_lsp.cssls) 9 | mlsp.load_lsp('mlua') 10 | -- vim.lsp.set_log_level("debug") 11 | 12 | -------------------------------------------------------------------------------- /lua/wind/plug/spectre.lua: -------------------------------------------------------------------------------- 1 | require('spectre').setup({ 2 | line_sep_start = '┌--------------------------------------------------------', 3 | line_sep = '└--------------------------------------------------------', 4 | }) 5 | 6 | if vim.g.wind_use_statusline == 1 then 7 | require('windline').add_status( 8 | require('spectre.state_utils').status_line() 9 | ) 10 | end 11 | -------------------------------------------------------------------------------- /local.lua: -------------------------------------------------------------------------------- 1 | local utils = import('core.utils') 2 | utils.set_vim_global({ 3 | wind_use_bg = 1, 4 | wind_use_agsort = 0, 5 | wind_use_treesitter = 0, 6 | 7 | wind_use_icon = 1, 8 | wind_use_dap = 0, 9 | wind_lsp_mode = 'lsp', 10 | wind_tmux_line = 1, 11 | wind_auto_close = 1, 12 | wind_use_indent = 1, 13 | wind_theme = 'wind', 14 | wind_statusline_theme = 'wind', 15 | }, true) 16 | -------------------------------------------------------------------------------- /lua/wind/plug/matchup.lua: -------------------------------------------------------------------------------- 1 | vim.api.nvim_exec([[ 2 | " disable match parent on insert mode 3 | function! ToggleMatchParent(status) 4 | if &buftype != 'nofile' 5 | if a:status == 1 6 | DoMatchParen 7 | else 8 | NoMatchParen 9 | endif 10 | endif 11 | endfunction 12 | 13 | augroup matchparent_wind 14 | autocmd! 15 | au InsertLeave * call ToggleMatchParent(1) 16 | au InsertEnter * call ToggleMatchParent(0) 17 | augroup END 18 | ]],false) 19 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/emmetls.lua: -------------------------------------------------------------------------------- 1 | local nvim_lsp = require'lspconfig' 2 | local configs = require'lspconfig/configs' 3 | 4 | configs.emmet_ls = { 5 | default_config = { 6 | cmd = {'node','/home/trieu/test/emmet-ls/out/server.js', '--stdio' }; 7 | filetypes = {'html', 'css' ,'scss','svelte','typescriptreact'}; 8 | root_dir = function() 9 | return vim.loop.cwd() 10 | end; 11 | settings = {}; 12 | }; 13 | } 14 | import('plug/lsp/lsp').lsp_setup(nvim_lsp.emmet_ls) 15 | 16 | -------------------------------------------------------------------------------- /lua/wind/plug/lspsaga.lua: -------------------------------------------------------------------------------- 1 | local lspsaga= require('lspsaga') 2 | -- local lsp=import('plug/lsp/lsp') 3 | -- local nnoremap = import('core.keymap').nnoremap 4 | 5 | lspsaga.init_lsp_saga({ 6 | code_action_prompt = { 7 | enable = false, 8 | sign = true, 9 | sign_priority = 20, 10 | virtual_text = true, 11 | }, 12 | code_action_keys = { quit = '',exec = '' }, 13 | rename_action_keys = { 14 | quit = '', exec = '' -- quit can be a table 15 | } 16 | }) 17 | 18 | -------------------------------------------------------------------------------- /lua/wind/plug/_end.lua: -------------------------------------------------------------------------------- 1 | require 'colorizer'.setup { 2 | 'css' ; 'scss' ; 'yml' ; 'yaml' ; 'vim' ; 'javascript' ; 'html' ; "rasi", "conf", "lua" 3 | } 4 | 5 | 6 | Wind.load_plug('me') 7 | import('general.autocmd').add_autocmd_color('whitespace',function () 8 | vim.cmd[[highlight ExtraWhitespace ctermbg=red guibg=red]] 9 | vim.cmd[[match ExtraWhitespace /\s\+$/]] 10 | end) 11 | 12 | 13 | 14 | require('Navigator').setup({ 15 | auto_save = 'current', 16 | disable_on_zoom = true 17 | }) 18 | 19 | 20 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/tsserver.lua: -------------------------------------------------------------------------------- 1 | 2 | local nvim_lsp = require('lspconfig') 3 | local function organize_imports() 4 | local params = { 5 | command = "_typescript.organizeImports", 6 | arguments = {vim.api.nvim_buf_get_name(0)}, 7 | title = "" 8 | } 9 | vim.lsp.buf.execute_command(params) 10 | end 11 | 12 | nvim_lsp.tsserver.commands = { 13 | OrganizeImports = { 14 | organize_imports, 15 | description = "Organize Imports" 16 | } 17 | } 18 | import('plug/lsp/lsp').lsp_setup(nvim_lsp.tsserver) 19 | -------------------------------------------------------------------------------- /local.sample.lua: -------------------------------------------------------------------------------- 1 | local utils = import('core.utils') 2 | utils.set_vim_global({ 3 | wind_use_bg = 1, 4 | wind_use_agsort = 0, 5 | wind_use_treesitter = 1, 6 | wind_use_icon = 1, 7 | wind_use_buffline = 1, 8 | wind_use_statusline = 1, 9 | wind_use_dap = 0, 10 | wind_lsp_mode = 'lsp', 11 | wind_tmux_line = 1, 12 | wind_auto_close = 1, 13 | wind_use_indent = 1, 14 | wind_theme = 'wind', 15 | wind_statusline_theme = 'wind', 16 | }, true) 17 | -------------------------------------------------------------------------------- /lua/wind/plug/eft.lua: -------------------------------------------------------------------------------- 1 | local keymap=import('core.keymap') 2 | keymap.nmap {'f' ,'(eft-f)'} 3 | keymap.xmap {'f' ,'(eft-f)'} 4 | keymap.omap {'f' ,'(eft-f)'} 5 | -- keymap." {'n'm,'ap F (e'}ft-F) 6 | -- keymap." {'x'm,'ap F (e'}ft-F) 7 | -- keymap." {'o'm,'ap F (e'}ft-F) 8 | keymap.nmap {'t' ,'(eft-t)'} 9 | keymap.xmap {'t' ,'(eft-t)'} 10 | keymap.omap {'t' ,'(eft-t)'} 11 | keymap.nmap {'T' ,'(eft-T)'} 12 | keymap.xmap {'T' ,'(eft-T)'} 13 | keymap.omap {'T' ,'(eft-T)'} 14 | -------------------------------------------------------------------------------- /plug/vim-floaterm.vim: -------------------------------------------------------------------------------- 1 | " let g:floaterm_wintype='normal' 2 | " let g:floaterm_height=40 3 | let g:floaterm_position='bottom' 4 | let g:floaterm_keymap_toggle = '' 5 | " let g:floaterm_keymap_next = '' 6 | " let g:floaterm_keymap_prev = '' 7 | " let g:floaterm_keymap_new = '' 8 | 9 | " Floaterm 10 | let g:floaterm_gitcommit='floaterm' 11 | let g:floaterm_title='' 12 | let g:floaterm_autoinsert=1 13 | let g:floaterm_width=0.9 14 | let g:floaterm_height=0.7 15 | let g:floaterm_wintitle=0 16 | let g:floaterm_autoclose=1 17 | -------------------------------------------------------------------------------- /lua/wind/general/themes/miramare.lua: -------------------------------------------------------------------------------- 1 | 2 | vim.g.miramare_palette = { 3 | light_grey= { '#928374', '245', 'LightGrey' }, 4 | grey = { '#928374', '245', 'LightGrey' } 5 | } 6 | vim.g.miramare_enable_italic = 0 7 | vim.g.miramare_disable_italic_comment = 1 8 | vim.g.miramare_transparent_background = vim.g.wind_use_bg == 1 9 | 10 | vim.api.nvim_exec([[ 11 | colorscheme miramare 12 | hi MatchParen ctermfg=172 ctermbg=none guibg=#d79921 guifg=#43A047 13 | hi IndentLine guifg=#37474F ctermfg=246 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE 14 | ]],true) 15 | 16 | 17 | -------------------------------------------------------------------------------- /lua/wind/plug/indent-blankline.lua: -------------------------------------------------------------------------------- 1 | 2 | -- Makes the vertical bars Green from term color 1 3 | -- vim.g.indentLine_color_term = 100 4 | vim.g.indentLine_char_list = { '┊','┊','┊','┊' } 5 | vim.g.indent_blankline_char = "┊" 6 | vim.g.indentLine_setConceal = 1 7 | vim.g.indentLine_conceallevel = 1 8 | vim.g.indentLine_concealcursor = "" 9 | vim.g.indent_blankline_char_highlight="IndentLine" 10 | -- vim.g.indent_blankline_char_highlight_list = { 'Error', 'Function' } 11 | vim.g.indentLine_fileTypeExclude = { "vifm","help","dashboard","fern",'lsp','which_key','sagahover' } 12 | -------------------------------------------------------------------------------- /snippets/markdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "link": { 3 | "prefix": "link", 4 | "body": ["[$0](http://example.com)"], 5 | "description": "link" 6 | }, 7 | "image": { 8 | "prefix": "image", 9 | "body": ["![$0](http://image.gif)"], 10 | "description": "image" 11 | }, 12 | "codeblock":{ 13 | "prefix" :"code", 14 | "body":["``` $0\n","```"] 15 | }, 16 | "table": { 17 | "prefix": "table", 18 | "body": [ 19 | "| Usage | KEY |", 20 | "| ------------- | ---------------------|", 21 | "| $0 | |" 22 | ], 23 | "description":"table" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/tailwind.lua: -------------------------------------------------------------------------------- 1 | 2 | local configs = require 'lspconfig/configs' 3 | local util = require 'lspconfig/util' 4 | local nvim_lsp = require('lspconfig') 5 | 6 | local server_name = 'tailwindls' 7 | 8 | configs[server_name] = { 9 | default_config = { 10 | cmd = {server_name}; 11 | filetypes = {'html','svelte','typescriptreact'}; 12 | root_dir = util.root_pattern("package.json", ".git"); 13 | }; 14 | docs = { 15 | description = [[ ]]; 16 | default_config = { 17 | root_dir = [[root_pattern("package.json", ".git")]]; 18 | }; 19 | } 20 | } 21 | 22 | 23 | import('plug/lsp/lsp').lsp_setup(nvim_lsp.tailwindls) 24 | 25 | -------------------------------------------------------------------------------- /lua/wind/core/env.lua: -------------------------------------------------------------------------------- 1 | local utils = import('core.utils') 2 | local local_env = string.format('%s/local.lua', Wind.vim_path) 3 | 4 | if vim.fn.filereadable(local_env) == 1 then 5 | vim.cmd("luafile " .. local_env) 6 | end 7 | 8 | utils.set_vim_global({ 9 | wind_use_agsort = 1, 10 | wind_use_plugin = 1, 11 | wind_use_bg = 1, 12 | wind_use_treesitter = 1, 13 | wind_use_icon = 1, 14 | wind_use_buffline = 1, 15 | wind_use_statusline = 1, 16 | wind_use_dap = 0, 17 | wind_lsp_mode = 'lsp', 18 | wind_tmux_line = 1, 19 | wind_auto_close = 1, 20 | wind_use_indent = 1, 21 | wind_theme = 'wind', 22 | wind_statusline_theme = 'wind', 23 | }, true) 24 | 25 | -------------------------------------------------------------------------------- /lua/wind/plug/web-devicons.lua: -------------------------------------------------------------------------------- 1 | require'nvim-web-devicons'.setup { 2 | -- your personnal icons can go here (to override) 3 | -- DevIcon will be appended to `name` 4 | override = { 5 | svelte = { 6 | icon = "", 7 | color = "#D50000", 8 | name = "svelte" 9 | }, 10 | 11 | folderopen = { 12 | icon = "", 13 | color = "#019833", 14 | name = "folderopen" 15 | }, 16 | folderclose = { 17 | icon = "", 18 | color = "#AA00FF", 19 | name = "folderopen" 20 | } 21 | }; 22 | -- globally enable default icons (default to false) 23 | -- will get overriden by `get_icons` option 24 | default = true; 25 | } 26 | vim.cmd[[ 27 | autocmd ColorScheme * lua require'nvim-web-devicons'.setup() 28 | ]] 29 | -------------------------------------------------------------------------------- /plug/vim-visual-multi.vim: -------------------------------------------------------------------------------- 1 | let g:VM_leader = ',' 2 | let g:VM_maps = {} 3 | let g:VM_maps['Find Under'] = '' " replace C-n 4 | let g:VM_maps['Find Subword Under'] = '' " replace visual C-n 5 | let g:VM_maps['Select Cursor Down'] = ',p' " start selecting down 6 | let g:VM_maps['Select Cursor Up'] = ',k' " start selecting up 7 | let g:VM_maps["Add Cursor Down"] = ',j' 8 | let g:VM_maps["Add Cursor Up"] = ',k' 9 | let g:VM_maps["Add Cursor At Pos"] = ',i' 10 | let g:VM_mouse_mappings = 1 11 | 12 | 13 | " c-d select word 14 | " q for skip current word 15 | " for gotto next" 16 | " tab to change mode 17 | " 18 | " 19 | ",, to start select by column ,j,k to add cursor up or down 20 | " better ,, then you mouse click :( 21 | 22 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/functions.lua: -------------------------------------------------------------------------------- 1 | local lsp = vim.lsp 2 | local M = {} 3 | 4 | M.organize_imports = function() 5 | local params = lsp.util.make_range_params() 6 | params.context = { 7 | diagnostics = {}, 8 | only = { 'source.organizeImports' } 9 | } 10 | 11 | local responses = lsp.buf_request_sync(0, 'textDocument/codeAction', params) 12 | 13 | if not responses or vim.tbl_isempty(responses) then 14 | return 15 | end 16 | 17 | for _, response in pairs(responses) do 18 | for _, result in pairs(response.result or {}) do 19 | if result.edit then 20 | lsp.util.apply_workspace_edit(result.edit) 21 | else 22 | lsp.buf.execute_command(result.command) 23 | end 24 | end 25 | end 26 | end 27 | 28 | vim.cmd[[ 29 | command! -nargs=* LspOrganizeImport call v:lua.import('plug/lsp/functions').organize_imports() 30 | ]] 31 | 32 | return M 33 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/angular.lua: -------------------------------------------------------------------------------- 1 | local configs = require 'lspconfig/configs' 2 | local util = require 'lspconfig/util' 3 | local nvim_lsp = require('lspconfig') 4 | 5 | local server_name = 'angularls' 6 | local bin_name = 'angularls' 7 | 8 | -- local installer = util.npm_installer { 9 | -- server_name = server_name; 10 | -- packages = { "@angular/language-server" }; 11 | -- binaries = { bin_name }; 12 | -- } 13 | 14 | configs[server_name] = { 15 | default_config = { 16 | cmd = {bin_name}; 17 | filetypes = {'html'}; 18 | root_dir = util.root_pattern("angular.json", ".git"); 19 | }; 20 | docs = { 21 | description = [[ ]]; 22 | default_config = { 23 | root_dir = [[root_pattern("angular.json", ".git")]]; 24 | }; 25 | } 26 | } 27 | 28 | -- configs[server_name].install = installer.install 29 | -- configs[server_name].install_info = installer.info 30 | 31 | import('plug/lsp/lsp').lsp_setup(nvim_lsp.angularls) 32 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/booster.lua: -------------------------------------------------------------------------------- 1 | local configs = require 'lspconfig/configs' 2 | local util = require 'lspconfig/util' 3 | local nvim_lsp = require('lspconfig') 4 | 5 | local server_name = 'jsboosterls' 6 | local bin_name = 'jsboosterls' 7 | 8 | local installer = util.npm_installer { 9 | server_name = server_name; 10 | packages = { "@angular/language-server" }; 11 | binaries = { bin_name }; 12 | } 13 | 14 | configs[server_name] = { 15 | default_config = { 16 | cmd = {'jsboosterls.sh'}; 17 | filetypes = {'javacript','typescript','typescriptreact'}; 18 | root_dir = util.root_pattern("package.json", ".git"); 19 | }; 20 | docs = { 21 | description = [[ ]]; 22 | default_config = { 23 | root_dir = [[root_pattern("package.json", ".git")]]; 24 | }; 25 | } 26 | } 27 | 28 | configs[server_name].install = installer.install 29 | configs[server_name].install_info = installer.info 30 | 31 | import('wind/lsp/lsp').lsp_setup(nvim_lsp.jsboosterls) 32 | 33 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/eslint.lua: -------------------------------------------------------------------------------- 1 | 2 | local configs = require 'lspconfig/configs' 3 | local util = require 'lspconfig/util' 4 | local nvim_lsp = require('lspconfig') 5 | 6 | local server_cmd = 'lsp_eslint' 7 | -- local server_cmd = 'node /home/trieu/.vscode/extensions/dbaeumer.vscode-eslint-2.1.14/server/out/eslintServer.js -f unix --stdin --stdin-filename' 8 | local server_name = "eslint" 9 | 10 | configs[server_name] = { 11 | default_config = { 12 | cmd = vim.fn.split(server_cmd, ' '); 13 | setting = { 14 | nodePath = '/home/trieu/.fnm/node-versions/v14.3.0/installation/bin/'; 15 | lala = '/home/trieu/.fnm/node-versions/v14.3.0/installation/bin/'; 16 | }; 17 | filetypes = {'html','typescript','typescriptreact'}; 18 | root_dir = util.root_pattern("package.json", ".git"); 19 | }; 20 | docs = { 21 | description = [[ ]]; 22 | default_config = { 23 | root_dir = [[root_pattern("package.json", ".git")]]; 24 | }; 25 | } 26 | } 27 | 28 | 29 | import('plug/lsp/lsp').lsp_setup(nvim_lsp[server_name]) 30 | 31 | -------------------------------------------------------------------------------- /ftplugin/svelte.vim: -------------------------------------------------------------------------------- 1 | if exists("b:did_ftplugin") 2 | finish 3 | endif 4 | 5 | " svelte {{{ 6 | 7 | let g:tagalong_additional_filetypes = ['svelte'] 8 | let g:closetag_filetypes = 'html,xhtml,phtml,svelte' 9 | let g:vim_svelte_plugin_use_typescript=1 10 | 11 | " }}} 12 | set foldmethod=manual 13 | nnoremap za zfat 14 | " delete tag in html 15 | nnoremap cx Td2f" 16 | nnoremap ul :call MyCodeFormat() 17 | 18 | " autocmd FileType svelte autocmd BufWritePre :Format 19 | 20 | " Example: set local options based on subtype 21 | function! OnChangeSvelteSubtype(subtype) 22 | " echom 'Subtype is '.a:subtype 23 | if empty(a:subtype) || a:subtype == 'html' 24 | setlocal commentstring= 25 | setlocal comments=s: 26 | elseif a:subtype =~ 'css' 27 | setlocal comments=s1:/*,mb:*,ex:*/ commentstring& 28 | else 29 | setlocal commentstring=//%s 30 | setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// 31 | endif 32 | endfunction 33 | " vim: set ts=8 sts=4 sw=4 expandtab : 34 | -------------------------------------------------------------------------------- /lua/wind/plug/formatter.lua: -------------------------------------------------------------------------------- 1 | local function prettier(args) 2 | if args == nil then args = {} end 3 | return function () 4 | args = vim.tbl_flatten({"--stdin-filepath", vim.api.nvim_buf_get_name(0), args}) 5 | return { 6 | exe = "prettier", 7 | args = args, 8 | stdin = true 9 | } 10 | end 11 | end 12 | local function rustywind() 13 | local args = vim.tbl_flatten({ vim.api.nvim_buf_get_name(0), '|', 'head', '-n', '-3', '|', 'tail', '-n', '+5'}) 14 | return { 15 | exe = "rustywind", 16 | args = args, 17 | stdin = true 18 | } 19 | end 20 | local default_prettier = prettier() 21 | require('formatter').setup({ 22 | filetype = { 23 | json = { default_prettier }, 24 | xml = { default_prettier }, 25 | scss = { default_prettier }, 26 | html = { default_prettier }, 27 | svelte = { rustywind}, 28 | javascript = { prettier({'--single-quote'}) }, 29 | javascriptreact = { prettier({'--single-quote'}) }, 30 | typescript = { prettier({'--single-quote'}) }, 31 | typescriptreact = { prettier({'--single-quote'}) }, 32 | } 33 | }) 34 | -------------------------------------------------------------------------------- /snippets/svelte.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "rinput":{ 4 | "prefix":"rinput", 5 | "body":"import { RImageUpload, RTabs } from '$components/ui/form/index';", 6 | "description":"" 7 | }, 8 | "rmodel":{ 9 | "prefix":"rmodel", 10 | "body":"import type { RModel } from '$common/model/rmodel';", 11 | "description":"" 12 | }, 13 | "ifelse":{ 14 | "description": "hifelse", 15 | "prefix": ["hif"], 16 | "body": [ 17 | "{#if $1}", 18 | "{:else}", 19 | "{/if}" 20 | ] 21 | }, 22 | "foreach":{ 23 | "prefix": "hfor", 24 | "body": [ 25 | "{#each list as comp}", 26 | "
  • $1
  • ", 27 | "{/each}" 28 | ], 29 | "description": "foreach" 30 | }, 31 | "dispatch":{ 32 | "prefix": "dispatch", 33 | "body": [ 34 | "import { createEventDispatcher } from 'svelte';", 35 | "const dispatch = createEventDispatcher();" 36 | ], 37 | "description": "event" 38 | }, 39 | "onMount":{ 40 | "prefix": "onMount", 41 | "body": [ 42 | "import { onMount } from 'svelte';", 43 | "onMount(() => {\n\n });" 44 | ] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lua/wind/plug/autopairs.lua: -------------------------------------------------------------------------------- 1 | local npairs = require('nvim-autopairs') 2 | -- local Cond= require('nvim-autopairs.conds') 3 | -- local ts_conds = require('nvim-autopairs.ts-conds') 4 | 5 | -- local endwise = require('nvim-autopairs.ts-rule').endwise 6 | npairs.setup({ 7 | fast_wrap = { 8 | end_key = 'L', 9 | highlight = 'HopNextKey', 10 | }, 11 | -- check_ts = true 12 | -- ignored_next_char = false 13 | -- enable_check_bracket_line = false 14 | }) 15 | 16 | 17 | 18 | vim.keymap.imap({ 19 | '', 20 | function() 21 | if vim.fn.pumvisible() ~= 0 then 22 | if vim.fn.complete_info()['selected'] ~= -1 then 23 | return vim.fn['compe#confirm'](vim.keymap.t('')) 24 | else 25 | vim.defer_fn(function() 26 | vim.fn['compe#confirm']('') 27 | end, 20) 28 | return vim.keymap.t('') 29 | end 30 | else 31 | return npairs.autopairs_cr() 32 | end 33 | end, 34 | expr = true, 35 | noremap = true, 36 | }) 37 | 38 | require("nvim-autopairs.completion.compe").setup({map_cr = false, map_complete = true}) 39 | -------------------------------------------------------------------------------- /queries/xml/highlights.scm: -------------------------------------------------------------------------------- 1 | (tag_name) @tag 2 | (erroneous_end_tag_name) @error 3 | (doctype) @constant 4 | (attribute_name) @property 5 | (attribute_value) @string 6 | (quoted_attribute_value) @string 7 | (comment) @comment 8 | 9 | ((element (start_tag (tag_name) @_tag) (text) @text.title) 10 | (#match? @_tag "^(h[0-9]|title)$")) 11 | 12 | ((element (start_tag (tag_name) @_tag) (text) @text.strong) 13 | (#match? @_tag "^(strong|b)$")) 14 | 15 | ((element (start_tag (tag_name) @_tag) (text) @text.emphasis) 16 | (#match? @_tag "^(em|i)$")) 17 | 18 | ((element (start_tag (tag_name) @_tag) (text) @text.strike) 19 | (#match? @_tag "^(s|del)$")) 20 | 21 | ((element (start_tag (tag_name) @_tag) (text) @text.underline) 22 | (#eq? @_tag "u")) 23 | 24 | ((element (start_tag (tag_name) @_tag) (text) @text.literal) 25 | (#match? @_tag "^(code|kbd)$")) 26 | 27 | ((element (start_tag (tag_name) @_tag) (text) @text.uri) 28 | (#eq? @_tag "a")) 29 | 30 | ((attribute 31 | (attribute_name) @_attr 32 | (quoted_attribute_value (attribute_value) @text.uri)) 33 | (#match? @_attr "^(href|src)$")) 34 | 35 | "=" @operator 36 | 37 | [ 38 | "<" 39 | "" 41 | "" 43 | ] @tag.delimiter 44 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/mlua.lua: -------------------------------------------------------------------------------- 1 | local nvim_lsp = require('lspconfig') 2 | 3 | nvim_lsp['sumneko_lua'].setup { 4 | cmd = { 5 | "/home/trieu/test/lua-language-server/bin/Linux/lua-language-server", 6 | "-E", 7 | "/home/trieu/test/lua-language-server/main.lua" 8 | }, 9 | on_attach =import('plug/lsp/lsp').on_attach_vim, 10 | settings = { 11 | Lua = { 12 | runtime = { 13 | -- Get the language server to recognize LuaJIT globals like `jit` and `bit` 14 | version = 'LuaJIT', 15 | -- Setup your lua path 16 | path = vim.split(package.path, ';'), 17 | }, 18 | diagnostics = { 19 | -- Get the language server to recognize the `vim` global 20 | globals = {'vim' , 'Wind', 'import' , 'describe' , 'it'}, 21 | }, 22 | workspace = { 23 | -- Make the server aware of Neovim runtime files 24 | library = { 25 | [vim.fn.expand('$VIMRUNTIME/lua')] = true, 26 | [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, 27 | }, 28 | }, 29 | }, 30 | }, 31 | } 32 | -------------------------------------------------------------------------------- /note.lua: -------------------------------------------------------------------------------- 1 | vim.g.wind_use_note = 1 2 | vim.g.wind_theme = 'gruvbox' 3 | vim.g.wind_use_indent = 0 4 | vim.g.gruvbox_contrast_light = 'medium' 5 | 6 | require('wind') 7 | 8 | vim.api.nvim_exec([[ 9 | set cursorline 10 | set linebreak " line break will break a character to next line 11 | set cmdheight=1 "reduce cmd height 12 | set norelativenumber nonumber noshowmode noshowcmd! hidden! noruler noshowcmd 13 | set laststatus=0 14 | "turn off signcolumn 15 | set signcolumn=no 16 | 17 | " hide status bar on which_key 18 | autocmd! FileType which_key 19 | 20 | " use it to re open file when open note 21 | augroup MyAutoWriteNote 22 | autocmd! 23 | autocmd BufReadPre *.md :silent !echo '%:p' > /tmp/$USER/my_note_file.txt 24 | augroup END 25 | " hi Normal guibg=#faf9dc guifg=#7c6f64 26 | ]],false) 27 | 28 | import('general.autocmd').add_autocmd_color('telescope',function () 29 | vim.api.nvim_exec([[ 30 | hi CursorLine ctermbg=255 ctermfg=16 31 | " change color on selected text 32 | highlight Visual cterm=NONE ctermbg=252 guifg=#ebdbb2 guibg=#000000 33 | highlight TelescopeMatching guifg=#0091EA 34 | highlight TelescopeSelection guifg=#CC241D gui=bold guibg=#ebdbb2 35 | highlight TelescopeSelectionCaret guifg=#CC241D " selection caret 36 | ]],false) 37 | end) 38 | -------------------------------------------------------------------------------- /lua/wind/general/themes/gruvbox.lua: -------------------------------------------------------------------------------- 1 | vim.g.gitgutter_override_sign_column_highlight = 1 2 | vim.g.gruvbox_sign_column = 1 3 | 4 | import('general.autocmd').add_autocmd_color('gruvbox',function () 5 | vim.api.nvim_exec([[ 6 | hi! link xmlTag GruvboxOrange 7 | hi! link htmlTag GruvboxOrange 8 | hi! link htmlTagN GruvboxOrange 9 | hi! link htmlTagName GruvboxOrange 10 | hi! link xmlEndTag GruvboxOrange 11 | hi! link xmlTagName GruvboxOrange 12 | hi! link xmlEqual GruvboxOrange 13 | hi LspDiagnosticsSignError guifg=#c43060 ctermfg=167 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE 14 | hi LspDiagnosticsSignWarning guifg=#f08e48 ctermfg=209 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE 15 | hi LspDiagnosticsSignInformation guifg=#c694ff ctermfg=177 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE 16 | hi LspDiagnosticsSignHint guifg=#1c8db2 ctermfg=31 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE 17 | 18 | hi link LspDiagnosticsVirtualTextError LspDiagnosticsSignError 19 | hi link LspDiagnosticsVirtualTextWarning LspDiagnosticsSignWarning 20 | hi link LspDiagnosticsVirtualTextInformation LspDiagnosticsSignInformation 21 | hi IndentLine guifg=#073d52 ctermfg=246 guibg=NONE ctermbg=NONE gui=NONE cterm=NONE 22 | hi MatchParen ctermfg=172 ctermbg=232 guifg=#d79921 guibg=#43A047 23 | ]],true) 24 | end) 25 | vim.cmd[[colorscheme gruvbox]] 26 | -------------------------------------------------------------------------------- /lua/wind/core/init.lua: -------------------------------------------------------------------------------- 1 | local check_dir = function () 2 | local data_dir = { 3 | Wind.cache_dir..'backup', 4 | Wind.cache_dir..'session', 5 | Wind.cache_dir..'undo' 6 | } 7 | if vim.fn.isdirectory(Wind.cache_dir) == 0 then 8 | os.execute("mkdir -p " .. Wind.cache_dir) 9 | for _,v in pairs(data_dir) do 10 | if vim.fn.isdirectory(v) == 0 then 11 | os.execute("mkdir -p " .. v) 12 | end 13 | end 14 | end 15 | end 16 | 17 | local function check_paq() 18 | local data_dir = string.format('%s/site/',vim.fn.stdpath('data')) 19 | local pag_dir = data_dir .. 'pack/paqs/opt/paq-nvim' 20 | local state = vim.loop.fs_stat(pag_dir) 21 | if not state then 22 | local cmd = "!git clone https://github.com/savq/paq-nvim.git " ..pag_dir 23 | vim.api.nvim_command(cmd) 24 | vim.loop.fs_mkdir(data_dir..'plugin',511,function() 25 | assert("make compile path dir failed") 26 | end) 27 | end 28 | end 29 | 30 | local function load_plug() 31 | vim.cmd 'packadd paq-nvim' -- Load package 32 | local paq = require'paq-nvim'.paq -- Import module and bind `paq` function 33 | paq{'savq/paq-nvim', opt = true} -- Let Paq manage itself 34 | end 35 | 36 | local function setup() 37 | vim.g.mapleader = " " 38 | check_dir() 39 | check_paq() 40 | load_plug() 41 | end 42 | 43 | setup() 44 | import('core.env') 45 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/efm.lua: -------------------------------------------------------------------------------- 1 | local nvim_lsp = require('lspconfig') 2 | local nvim_setup=import('plug/lsp/lsp') 3 | 4 | local prettier = { 5 | formatCommand = "./node_modules/.bin/prettier --stdin --stdin-filepath ${INPUT}", 6 | formatStdin = true 7 | } 8 | local eslint = { 9 | lintCommand = "eslint -f unix --stdin --stdin-filename ${INPUT}", 10 | lintIgnoreExitCode = true, 11 | lintStdin = true, 12 | lintFormats = {"%f:%l:%c: %m"}, 13 | } 14 | local languages = { 15 | --lua = {luafmt}, 16 | typescript = { eslint}, 17 | javascript = {prettier, eslint}, 18 | typescriptreact = {prettier, eslint}, 19 | ['typescript.tsx'] = {prettier, eslint}, 20 | javascriptreact = {prettier, eslint}, 21 | ['javascript.jsx'] = {prettier, eslint}, 22 | yaml = {prettier}, 23 | json = {prettier}, 24 | html = {prettier}, 25 | scss = {prettier}, 26 | css = {prettier}, 27 | markdown = {prettier}, 28 | } 29 | nvim_lsp.efm.setup{ 30 | on_attach = nvim_setup.on_attach_vim, 31 | root_dir = nvim_lsp.util.root_pattern("package.json", ".git", vim.fn.getcwd()), 32 | filetypes = vim.tbl_keys(languages), 33 | init_options = { 34 | documentFormatting = true, 35 | codeAction = true 36 | }, 37 | settings = { 38 | rootMarkers = { "package.json", ".git" }, 39 | lintDebounce = 500, 40 | languages = languages 41 | }, 42 | } 43 | -- require('plug/lsp/lsp').lsp_setup(nvim_lsp.diagnosticls) 44 | -------------------------------------------------------------------------------- /plug/gitopen.vim: -------------------------------------------------------------------------------- 1 | " https://github.com/tpope/vim-rhubarb/blob/master/autoload/rhubarb.vim#L28-L33 2 | " replace it because netrw 3 | function! s:gh_home_url(url) abort 4 | let domain_pattern = 'github\.com' 5 | let domains = get(g:, 'github_enterprise_urls', get(g:, 'fugitive_github_domains', [])) 6 | for domain in domains 7 | let domain_pattern .= '\|' . escape(split(substitute(domain, '/$', '', ''), '://')[-2], '.') 8 | endfor 9 | let base = matchstr(a:url, '^\%(https\=://\%([^@/:]*@\)\=\|git://\|git@\|ssh://git@\|org-\d\+@\|ssh://org-\d\+@\)\=\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=/\=$') 10 | if index(domains, 'http://' . matchstr(base, '^[^:/]*')) >= -1 11 | return 'http://' . tr(base, ':', '/') 12 | elseif !empty(base) 13 | return 'https://' . tr(base, ':', '/') 14 | else 15 | return '' 16 | endif 17 | endfunction 18 | 19 | function! WindGitOpen(...) 20 | let l:remote = fugitive#repo().config('remote.origin.url') 21 | let l:branch = fugitive#head() 22 | let l:url = s:gh_home_url(l:remote) 23 | let l:url = printf("%s/blob/%s/%s", l:url, l:branch, a:1['path']) 24 | if a:1['line1'] >1 && a:1['line2']>1 25 | let l:url = printf("%s#L%s-L%s",l:url ,a:1['line1'],a:1['line2']) 26 | endif 27 | return shellescape(l:url) 28 | endfunction 29 | 30 | let g:fugitive_browse_handlers = [ function ('WindGitOpen') ] 31 | function! WindOpen(...) 32 | call system(wind#open() . ' ' . a:1) 33 | endfunction 34 | command! -nargs=* Browse call WindOpen() 35 | 36 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lang/svelte.lua: -------------------------------------------------------------------------------- 1 | local configs = require 'lspconfig/configs' 2 | local nvim_lsp = require('lspconfig') 3 | local util = require 'lspconfig/util' 4 | 5 | local server_name = 'svelte' 6 | local bin_name = 'svelteserver' 7 | 8 | 9 | configs[server_name] = { 10 | default_config = { 11 | cmd = {bin_name, '--stdio'}; 12 | filetypes = {'svelte'}; 13 | root_dir = util.root_pattern("package.json" ); 14 | }; 15 | docs = { 16 | description = [[ 17 | ```sh 18 | npm install -g svelte-language-server 19 | ``` 20 | ]]; 21 | default_config = { 22 | root_dir = [[root_pattern("package.json" )]]; 23 | }; 24 | } 25 | } 26 | 27 | vim.cmd[[ 28 | autocmd BufWritePost *.ts lua require('wind.plug.lsp.lang.svelte').svelte_update() 29 | ]] 30 | 31 | 32 | import('plug/lsp/lsp').lsp_setup(nvim_lsp.svelte) 33 | 34 | local M ={} 35 | function M.svelte_update() 36 | local buffList = vim.fn.getbufinfo({ 37 | bufloaded = 1; 38 | buflisted = 1 39 | }) 40 | for _, buf in pairs(buffList) do 41 | if string.match(buf.name,".*svelte$") then 42 | if buf.bufnr then 43 | local bufnr = vim.fn.bufnr('%') 44 | local uri = vim.uri_from_bufnr(bufnr) 45 | local text= require('wind.core.utils').buf_get_full_text(bufnr) 46 | local params = { 47 | uri = uri; 48 | changes = { { text = text } } 49 | } 50 | vim.lsp.buf_notify(buf.bufnr, '$/onDidChangeTsOrJsFile', params) 51 | end 52 | end 53 | end 54 | end 55 | return M 56 | -------------------------------------------------------------------------------- /lua/wind/plug/treesitter.lua: -------------------------------------------------------------------------------- 1 | 2 | local hiLink= import('core.utils').hiLink 3 | local ts = require 'nvim-treesitter.configs' 4 | local keymap = import('core.keymap') 5 | -- local parser_config = require"nvim-treesitter.parsers".get_parser_configs() 6 | 7 | -- parser_config.svelte = { 8 | -- install_info = { 9 | -- url = "~/test/tree-sitter-svelte", -- local path or git repo 10 | -- files = {"src/parser.c", "src/scanner.cc"} 11 | -- }, 12 | -- filetype = "svelte", 13 | -- used_by = {"svelte"} 14 | -- } 15 | 16 | -- parser_config.xml = { 17 | -- install_info = { 18 | -- url = "https://github.com/windwp/tree-sitter-html", 19 | -- files = { "src/parser.c", "src/scanner.cc" }, 20 | -- }, 21 | -- filetype = "xml", 22 | -- used_by = {"xml"} 23 | -- } 24 | 25 | ts.setup { 26 | ensure_installed = 'maintained', 27 | highlight = {enable = true}, 28 | indent = { 29 | enable = false 30 | }, 31 | autotag = { 32 | enable = true, 33 | } 34 | } 35 | 36 | -- https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/javascript/highlights.scm 37 | -- https://github.com/nvim-treesitter/nvim-treesitter/blob/7edf1d1c2bfb4bdc53319494697ca2947920b69e/lua/nvim-treesitter/highlight.lua 38 | if vim.g.wind_theme == 'miramare' then 39 | hiLink('TSVariableBuiltin','Purple') 40 | hiLink('TSConstructor','Cyan') 41 | hiLink('TSProperty','White') 42 | end 43 | vim.cmd[[set foldmethod=expr]] 44 | vim.cmd[[ set foldexpr=nvim_treesitter#foldexpr() ]] 45 | keymap.nnoremap({'.', ':TSHighlightCapturesUnderCursor'}) 46 | -------------------------------------------------------------------------------- /ftplugin/javascript.vim: -------------------------------------------------------------------------------- 1 | setlocal path=.,src 2 | setlocal suffixesadd=.js,.jsx,.ts,.tsx 3 | setlocal foldmethod=syntax 4 | " set formatoptions-=ro 5 | " Source: 6 | " https://damien.pobel.fr/post/configure-neovim-vim-gf-javascript-import/ 7 | " TODO more robust solution (detect root directory, specific to javascript, 8 | " ...) 9 | function! s:find_node_modules_filename(fname) abort 10 | let nodeModules = "./node_modules/" 11 | let packageJsonPath = nodeModules . a:fname . "/package.json" 12 | if filereadable(packageJsonPath) 13 | return nodeModules . a:fname . "/" . json_decode(join(readfile(packageJsonPath))).main 14 | else 15 | let checkfname="@".a:fname 16 | let packageJsonPath = nodeModules . checkfname . "/package.json" 17 | if filereadable(packageJsonPath) 18 | return nodeModules . checkfname. "/" . json_decode(join(readfile(packageJsonPath))).main 19 | elseif filereadable( nodeModules . a:fname ) 20 | return nodeModules . a:fname 21 | elseif filereadable(nodeModules ."@". a:fname) 22 | return nodeModules ."@" . a:fname 23 | endif 24 | endif 25 | endfunction 26 | 27 | " Used in 'includeexpr' to resolve file names 28 | function! Js_includeexpr(filename) abort 29 | let fname = s:find_node_modules_filename(a:filename) 30 | if filereadable(fname) 31 | return fname 32 | endif 33 | endfunction 34 | 35 | setlocal includeexpr=Js_includeexpr(v:fname) 36 | 37 | " disable match parent in insert mode for better cursor on pairs bracket 38 | " autocmd InsertEnter :NoMatchParen 39 | " autocmd InsertLeave :DoMatchParen 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## NEOVIM Config - Windvim 2 | 3 | ![demo](https://i.imgur.com/Fr9uQO7.png) 4 | 5 | ## Install 6 | ``` bash 7 | ./scripts/setup.sh 8 | 9 | ``` 10 | ## Plugins 11 | 12 | * [Paq](https://github.com/savq/paq-nvim) 13 | * [Telescope](https://github.com/nvim-telescope/telescope.nvim) 14 | * [windline](https://github.com/windwp/windline.nvim) 15 | 16 | 17 | ## Plug 18 | 19 | I use [Paq](https://github.com/savq/paq-nvim) and create a function Plug so I can use it like (vim-plug) 20 | with Plug you can customize it to load config from lua or vim 21 | 22 | ``` lua 23 | 24 | Plug {'neoclide/jsonc.vim' , ft = 'json'} 25 | Plug {'junegunn/gv.vim' , on = 'GV'} 26 | 27 | 28 | 29 | -- load vim file in /plug/fern.vim 30 | Plug {'lambdalisue/fern.vim' , config = 'fern.vim'} 31 | 32 | ``` 33 | Plug can lazy load with filetype(ft),command(on), event and key. 34 | 35 | I don't need to rename Plug to `paq` or `use` 36 | 37 | All plugins config is store on folder /plug/.vim and /lua/wind/plug/.lua 38 | 39 | If you are develop or test config you can run command `:WindDev`. 40 | It will enable dev mode and all import module is auto reload. 41 | 42 | 43 | ## LSP 44 | 45 | by default it load some lsp server lua, jsonls, yamls. 46 | 47 | Another lsp can load when you open project and run script with my plugin 48 | [project-config](https://github.com/windwp/nvim-projectconfig) 49 | 50 | ``` lua 51 | 52 | Wind.load_lsp {'tsserver', 'efm'} 53 | Wind.load_lsp 'gopls' 54 | 55 | Wind.load_theme 'gruvbox' 56 | 57 | ``` 58 | ## Thanks 59 | 60 | * [habamax](https://github.com/habamax/) 61 | * [tjdevries](https://github.com/tjdevries) 62 | * [glepnir](https://github.com/glepnir) 63 | 64 | -------------------------------------------------------------------------------- /lua/wind/plug/windline/animation.lua: -------------------------------------------------------------------------------- 1 | local animation = require('wlanimation') 2 | local effects = require('wlanimation.effects') 3 | 4 | local blue_colors = { 5 | '#90CAF9', 6 | '#64B5F6', 7 | '#42A5F5', 8 | '#2196F3', 9 | '#1E88E5', 10 | '#1976D2', 11 | '#1565C0', 12 | '#0D47A1', 13 | } 14 | 15 | local function play() 16 | if Wind.state.animation==true then 17 | Wind.state.animation=false 18 | animation.stop_all() 19 | else 20 | animation.stop_all() 21 | Wind.state.animation=true 22 | animation.animation({ 23 | data = { 24 | { 'waveleft1', effects.list_color(blue_colors, 6) }, 25 | { 'waveleft2', effects.list_color(blue_colors, 5) }, 26 | { 'waveleft3', effects.list_color(blue_colors, 4) }, 27 | { 'waveleft4', effects.list_color(blue_colors, 3) }, 28 | { 'waveleft5', effects.list_color(blue_colors, 2) }, 29 | }, 30 | -- timeout = 100, 31 | delay = 200, 32 | interval = 150, 33 | }) 34 | 35 | animation.animation({ 36 | data = { 37 | { 'waveright1', effects.list_color(blue_colors, 2) }, 38 | { 'waveright2', effects.list_color(blue_colors, 3) }, 39 | { 'waveright3', effects.list_color(blue_colors, 4) }, 40 | { 'waveright4', effects.list_color(blue_colors, 5) }, 41 | { 'waveright5', effects.list_color(blue_colors, 6) }, 42 | }, 43 | -- timeout = 100, 44 | delay = 200, 45 | interval = 150, 46 | }) 47 | end 48 | end 49 | 50 | return { 51 | play = play, 52 | } 53 | -------------------------------------------------------------------------------- /lua/wind/plug/gitsigns.lua: -------------------------------------------------------------------------------- 1 | require('gitsigns').setup { 2 | signs = { 3 | add = {hl = 'GitGutterAdd' , text = '┃', numhl='GitSignsAddNr' , linehl='DiffAdd'}, 4 | change = {hl = 'GitGutterChange', text = '┃', numhl='GitSignsChangeNr', linehl='DiffChange'}, 5 | -- delete = {hl = 'GitGutterDelete', text = 'ﬠ', numhl='GitSignsDeleteNr', linehl='DiffDelete'}, 6 | -- topdelete = {hl = 'GitGutterDelete', text = 'ﬢ', numhl='GitSignsDeleteNr' ,linehl='DiffDelete'}, 7 | delete = {hl = 'GitGutterDelete', text = '┃', numhl='GitSignsDeleteNr', linehl='DiffDelete', show_count = true}, 8 | topdelete = {hl = 'GitGutterDelete', text = '▔', numhl='GitSignsDeleteNr' ,linehl='DiffDelete', show_count = true}, 9 | changedelete = {hl = 'GitGutterDelete', text = '┃', numhl='GitSignsChangeNr', linehl='DiffDelete', show_count = true}, 10 | }, 11 | numhl = false, 12 | linehl = false, 13 | keymaps = { 14 | -- Default keymap options 15 | noremap = true, 16 | buffer = true, 17 | 18 | ['n gj'] = 'lua require"gitsigns".next_hunk()', 19 | ['n gk'] = 'lua require"gitsigns".prev_hunk()', 20 | 21 | -- ['n hs'] = 'lua require"gitsigns".stage_hunk()', 22 | -- ['n hu'] = 'lua require"gitsigns".undo_stage_hunk()', 23 | ['n gu'] = 'lua require"gitsigns".reset_hunk()', 24 | ['n gR'] = ':Gread', -- reset buffer 25 | ['n gh'] = 'lua require"gitsigns".preview_hunk()', 26 | ['n gb'] = 'lua require"gitsigns".blame_line()', 27 | 28 | -- Text objects 29 | -- ['o ih'] = ':lua require"gitsigns".text_object()', 30 | -- ['x ih'] = ':lua require"gitsigns".text_object()' 31 | }, 32 | watch_index = { 33 | interval = 1000 34 | }, 35 | sign_priority = 6, 36 | update_debounce = 100, 37 | status_formatter = nil, -- Use default 38 | use_decoration_api = true, 39 | use_internal_diff = true, -- If luajit is present 40 | } 41 | -------------------------------------------------------------------------------- /plugin/foldtext.vim: -------------------------------------------------------------------------------- 1 | 2 | "" Name: plugin/foldtext.vim 3 | "" Author: Maxim Kim 4 | "" https://github.com/habamax/.vim/blob/master/plugin/foldtext.vim 5 | 6 | set foldtext=MyFoldText() 7 | func! MyFoldText() 8 | let foldchar = get(b:, 'foldchar', '•') 9 | let strip_comments = get(b:, 'foldtext_strip_comments', v:false) 10 | let strip_add_regex = get(b:, 'foldtext_strip_add_regex', '') 11 | 12 | let line = getline(v:foldstart) 13 | 14 | " markdown frontmatter -- just take the next line hoping it would be 15 | " title: Your title 16 | if line =~ '^----*$' 17 | let line = getline(v:foldstart+1) 18 | endif 19 | 20 | let indent = indent(v:foldstart) 21 | 22 | let foldlevel = repeat(foldchar, v:foldlevel) 23 | let foldindent = repeat(' ', max([indent-strdisplaywidth(foldlevel), strdisplaywidth(foldchar)])) 24 | let foldlines = (v:foldend - v:foldstart + 1) 25 | 26 | " always strip away fold markers 27 | let strip_regex = '\%(\s*{{{\d*\s*\)' 28 | if strip_comments 29 | let strip_regex .= '\|\%(^\s*' 30 | \. substitute(&commentstring, '\s*%s\s*', '', '') 31 | \. '*\s*\)' 32 | endif 33 | let line = substitute(line, strip_regex, '', 'g') 34 | 35 | " additional per buffer strip 36 | if strip_add_regex != "" 37 | let line = substitute(line, strip_add_regex, '', 'g') 38 | endif 39 | 40 | let line = substitute(line, '^\s*\|\s*$', '', 'g') 41 | let line = substitute(line, '^"', '', 'g') 42 | let line = substitute(line, ':$', '', 'g') 43 | 44 | 45 | let nontextlen = strdisplaywidth(foldlevel.foldindent.foldlines.' ()') 46 | let foldtext = strcharpart(line, 0, winwidth(0) - nontextlen) 47 | let foldtext="[".foldtext." ]" 48 | 49 | let foldlines_padding = ' ' 50 | 51 | return printf("%s%s%s%s(%d) ", 52 | \ foldlevel, 53 | \ foldindent, 54 | \ foldtext, 55 | \ foldlines_padding, 56 | \ foldlines) 57 | endfunc 58 | -------------------------------------------------------------------------------- /lua/wind/plug/me/alternate.lua: -------------------------------------------------------------------------------- 1 | -- fast switch to another file match pattern 2 | -- vim.g.wind_switch_file = { 3 | -- { 4 | -- source = "main.svelte", 5 | -- target = "editor.svelte" 6 | -- }, 7 | -- { 8 | -- source = "editor.svelte", 9 | -- target = "main.svelte" 10 | -- }, 11 | -- } 12 | local M={} 13 | local nav=import('core.nav') 14 | 15 | local function getTargetPath(prefix) 16 | 17 | if vim.g.wind_switch_file == nil then 18 | print("Not have a config file") 19 | return 20 | end 21 | local filename = vim.fn.expand("%:t") 22 | local data = vim.g.wind_switch_file 23 | -- TEST 24 | -- filename="dio.lua" 25 | -- local data = { 26 | -- { 27 | -- source = ".*%.lua", 28 | -- target = "yank.xml" 29 | -- }, 30 | -- { 31 | -- source = ".*%.html", 32 | -- target = "{}.ts" 33 | -- }, 34 | -- { 35 | -- source = ".*%.ts", 36 | -- target = "{}.html" 37 | -- }, 38 | -- } 39 | local path='' 40 | for _,item in pairs(data) do 41 | if filename:match(item.source) then 42 | path = vim.fn.expand("%:h") 43 | if item.target:match("{}") then 44 | filename=filename:gsub("%.%w*$","") 45 | local targetName=string.gsub(item.target,"{}",filename) 46 | path = path .. "/"..targetName 47 | else 48 | path = path .. "/"..item.target 49 | end 50 | if prefix ~= nil then 51 | if not path:match(prefix..'$') then 52 | path = "not valid" 53 | end 54 | end 55 | if vim.fn.filereadable(path) == 1 then 56 | return path 57 | end 58 | end 59 | end 60 | return "" 61 | end 62 | function M.switch(prefix) 63 | local target=getTargetPath(prefix) 64 | if vim.fn.filereadable(target) == 1 then 65 | nav.tabOpen(target) 66 | return 67 | end 68 | end 69 | 70 | function M.vsplit(prefix) 71 | local target=getTargetPath(prefix) 72 | if vim.fn.filereadable(target) == 1 then 73 | local windowId = nav.get_window_id(target) 74 | if windowId and windowId > 0 then 75 | vim.fn.win_gotoid(windowId) 76 | else 77 | vim.cmd (":vsplit " .. target) 78 | end 79 | return 80 | end 81 | end 82 | 83 | return M 84 | -------------------------------------------------------------------------------- /lua/wind/plug/compe.lua: -------------------------------------------------------------------------------- 1 | local keymap = import('core.keymap') 2 | 3 | require'compe'.setup { 4 | enabled = true, 5 | debug = true, 6 | min_length = 2, 7 | preselect = "disable", 8 | source_timeout = 200, 9 | incomplete_delay = 400, 10 | allow_prefix_unmatch = false, 11 | source = { 12 | path = true; 13 | buffer = true; 14 | vsnip = true; 15 | nvim_lsp = true; 16 | nvim_lua = true; 17 | }; 18 | } 19 | require('vim.lsp.protocol').CompletionItemKind = { 20 | ''; -- Text = 1; 21 | ''; -- Method = 2; 22 | 'ƒ'; -- Function = 3; 23 | ''; -- Constructor = 4; 24 | ''; -- Field = 5; 25 | ''; -- Variable = 6; 26 | ''; -- Class = 7; 27 | 'ﰮ'; -- Interface = 8; 28 | ''; -- Module = 9; 29 | ''; -- Property = 10; 30 | ''; -- Unit = 11; 31 | ''; -- Value = 12; 32 | '了'; -- Enum = 13; 33 | ''; -- Keyword = 14; 34 | '﬌'; -- Snippet = 15; 35 | ''; -- Color = 16; 36 | ''; -- File = 17; 37 | ''; -- Reference = 18; 38 | ''; -- Folder = 19; 39 | ''; -- EnumMember = 20; 40 | ''; -- Constant = 21; 41 | ''; -- Struct = 22; 42 | "⌘"; -- Event = 23; 43 | ""; -- Operator = 24; 44 | "♛"; -- TypeParameter = 25; 45 | } 46 | 47 | 48 | 49 | keymap.imap({'',function () 50 | if vim.fn.pumvisible() == 1 then 51 | if vim.fn.complete_info()["selected"] ~= -1 then 52 | return vim.fn["compe#confirm"]() 53 | else 54 | return keymap.t("a") 55 | end 56 | elseif vim.fn.call("vsnip#available", {1}) == 1 then 57 | return keymap.t "(vsnip-expand-or-jump)" 58 | else 59 | return keymap.t"" 60 | end 61 | end, expr = true, noremap = false}) 62 | 63 | keymap.imap({'', 'compe#complete()',silent = true, expr = true, noremap = true}) 64 | -------------------------------------------------------------------------------- /lua/wind/plug/_start.lua: -------------------------------------------------------------------------------- 1 | -- vim: foldmethod=marker sw=2 formatoptions-=o foldlevel=0 2 | 3 | vim.g.lens_disabled_filetypes = {'fugitiveblame', 'fern', 'selectprompt', 'selectresults','quickfix','qf','which_key'} 4 | 5 | -- Match up {{{ 6 | vim.g.loaded_matchparen = 1 7 | vim.g.matchup_matchparen_offscreen = { method= 'popup'} 8 | vim.g.matchup_matchpref = { 9 | svelte = { tagnameonly = 1, }, 10 | vue = { tagnameonly = 1, }, 11 | typescriptreact = { tagnameonly = 1, }, 12 | html = { tagnameonly = 1, }, 13 | } 14 | 15 | -- }}} 16 | 17 | -- Compe {{{ 18 | vim.g.loaded_compe_treesitter = 1 19 | vim.g.loaded_compe_calc = 1 20 | vim.g.loaded_compe_snippets_nvim = 1 21 | vim.g.loaded_compe_spell = 1 22 | vim.g.loaded_compe_vim_lsc = 1 23 | vim.g.loaded_compe_vim_lsp = 1 24 | -- }}} 25 | 26 | -- Markdown : {{{ 27 | vim.g.vim_markdown_no_default_key_mappings = 1 28 | vim.g.vim_markdown_new_list_item_indent = 0 29 | vim.g.vim_markdown_auto_insert_bullets = 1 30 | vim.g.vim_markdown_follow_anchor = 1 31 | vim.g.vim_markdown_conceal_code_blocks = 0 32 | vim.g.vim_markdown_anchorexpr = [['^#\\\+ *'.v:anchor.'$']] 33 | 34 | vim.api.nvim_exec([[ 35 | augroup markdown_tool 36 | autocmd! 37 | autocmd BufReadPost *.md call FixVimMarkdown() 38 | autocmd InsertLeave *.md call FixMdTable() 39 | augroup END 40 | ]],true) 41 | 42 | -- }}} 43 | 44 | -- GitGutter {{{ 45 | 46 | vim.g.gitgutter_sign_added = '┃' 47 | vim.g.gitgutter_sign_modified = '┃' 48 | vim.g.gitgutter_sign_removed = '┃' 49 | 50 | --}}} 51 | 52 | -- Conflict Marker {{{ 53 | 54 | vim.g.conflict_marker_highlight_group = '' 55 | vim.g.conflict_marker_begin = '^<<<<<<< .*$' 56 | vim.g.conflict_marker_end = '^>>>>>>> .*$' 57 | 58 | --}}} 59 | 60 | -- hight light extra white space 61 | 62 | 63 | vim.g.EasyMotion_smartcase = 1 64 | vim.g.switch_mapping = "gst" 65 | vim.g.switch_custom_definitions = { 66 | {'0', '1'}, 67 | {'const', 'let', 'var'} 68 | } 69 | 70 | vim.g.undotree_SetFocusWhenToggle = 1 71 | vim.g.no_default_tabular_maps = 0 72 | 73 | -- "custom vifm to display image 74 | vim.g.vifm_exec ='$HOME/.config/vifm/scripts/vifmrun' 75 | 76 | vim.g.vsnip_snippet_dir = Wind.vim_path .. "/snippets" 77 | 78 | -- TmuxLine {{{ 79 | 80 | if vim.g.wind_tmux_line == 1 then 81 | vim.g.tpipeline_tabline = 1 82 | import('general.autocmd').add_autocmd_enter('tpipe', function () 83 | vim.cmd[[let g:tpipeline_statusline = &tabline]] 84 | vim.cmd[[set conceallevel=2]] 85 | end) 86 | end 87 | --}}} 88 | -------------------------------------------------------------------------------- /lua/wind/general/autocmd.lua: -------------------------------------------------------------------------------- 1 | local vim = vim 2 | local autocmd = {} 3 | 4 | function autocmd.nvim_create_augroups(definitions) 5 | for group_name, definition in pairs(definitions) do 6 | vim.api.nvim_command('augroup '..group_name) 7 | vim.api.nvim_command('autocmd!') 8 | for _, def in ipairs(definition) do 9 | local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ') 10 | vim.api.nvim_command(command) 11 | end 12 | vim.api.nvim_command('augroup END') 13 | end 14 | end 15 | function autocmd.setup() 16 | if Wind.__autocmd_setup then return end 17 | Wind.__autocmd_setup = true 18 | local definitions = { 19 | lens ={ 20 | {"BufWinEnter,WinEnter" ,"*", "silent! call win#lens()"} 21 | }, 22 | bufs = { 23 | {"BufWritePre","*.tmp","setlocal noundofile"}; 24 | {"BufWritePre","*.log","setlocal noundofile"}; 25 | {"BufWritePre","*.bak","setlocal noundofile"}; 26 | }; 27 | wins = { 28 | -- write file when focus lost 29 | {'FocusLost','*','silent! wa'}, 30 | -- if open 2 buffer in diffrent tab close it 31 | -- {"BufEnter" , '*' , "call v:lua.import('core.nav').on_buffer_open(expand(''))"}; 32 | {"VimEnter" , "*" , "lua import('general.autocmd').on_enter()"}; 33 | {"ColorScheme" , "*" , "lua import('general.autocmd').on_color()"} 34 | }; 35 | ft = { 36 | {"FileType", "typescript,typescriptreact,javascript", "imap ; ;:lua require('nvim-autospace').format(999)A"}, 37 | }; 38 | lsp = { 39 | {"BufWritePre" ,"*.tsx", ":Format"} 40 | }; 41 | yank = { 42 | {"TextYankPost", [[* silent! lua vim.highlight.on_yank({higroup="IncSearch", timeout=400})]]}; 43 | }; 44 | } 45 | 46 | autocmd.nvim_create_augroups(definitions) 47 | end 48 | 49 | 50 | Wind.enter_event = Wind.enter_event or {} 51 | Wind.color_event = Wind.color_event or {} 52 | 53 | 54 | autocmd.add_autocmd_enter = function(name, func) 55 | Wind.enter_event[name] = func 56 | end 57 | 58 | autocmd.on_enter = function() 59 | for _, handler in pairs(Wind.enter_event) do 60 | handler() 61 | end 62 | end 63 | 64 | autocmd.add_autocmd_color = function(name, func,add_to_enter) 65 | Wind.color_event[name] = func 66 | if add_to_enter then 67 | Wind.enter_event[name] = func 68 | end 69 | end 70 | 71 | autocmd.on_color = function() 72 | for _, handler in pairs(Wind.color_event) do 73 | handler() 74 | end 75 | end 76 | 77 | autocmd.setup() 78 | return autocmd 79 | -------------------------------------------------------------------------------- /lua/wind/general/keys.lua: -------------------------------------------------------------------------------- 1 | local map = import('core.keymap') 2 | local n, i, v, x = 3 | map.nnoremap, map.inoremap, map.vnoremap, map.xnoremap 4 | 5 | 6 | n({'ev',':tabnew ~/.config/nvim/init.lua | tcd ~/.config/nvim/' , 'edit vim' } ) 7 | n({'ep','lua require("nvim-projectconfig").edit_project_config()' , 'edit project current folder' } ) 8 | n({'ec',':TabCustomOpen ~/.config/alacritty/alacritty.yml' , 'edit alacritty' } ) 9 | n({'en',':TabCustomOpen ~/work/md-note/index.md' , 'edit note' } ) 10 | n({'ei',':TabCustomOpen ~/.config/regolith/i3/config' , 'edit i3' } ) 11 | n({'ed',':TabCustomOpen ~/dotfiles/install/env.sh' , 'edit dotfiles' } ) 12 | n({'ew',':TabCustomOpen ~/.local/share/nvim/site/pack/paqs/start/wind-colors/lua/wind-colors.lua' , 'edit dotfiles' } ) 13 | 14 | n({'h', 's', 'split horizontal'}) 15 | n({'q', ':call wind#QfToggle()', 'toggle quick fix'}) 16 | n({'v', 'v', 'split vertical'}) 17 | n({'z', ':setlocal spell! spell?', 'toggle spell'}) 18 | 19 | n({'s', ':HopChar2', 'jump to word'}) 20 | 21 | n({'u9', 'lua import("plug.windline.animation").play()', 'run animation'}) 22 | n({'um', ':MyRedir messages', 'log output message'}) 23 | n({'ur', ':call ToggleResizeMode()', 'toggle resize mode'}) 24 | n({'ud', ":windo diffthis", "set test command"}) 25 | 26 | n({'gx', "lua import('core.nav').open_or_search(0)", 'open or search '}) 27 | v({'gx', ":call v:lua.import('core.nav').open_or_search(1)",'open_or_search'}) 28 | n({'gb', "lua import('core.nav').go_back()", 'go back'}) 29 | n({'gk', "lua import('core.nav').goto_buff_or_qf('previous')","goto previous"}) 30 | n({'gj', "lua import('core.nav').goto_buff_or_qf('next')", "goto next"}) 31 | 32 | 33 | n({'', "lua Wind.load_plug('copyq').show()"}) 34 | i({'', ":lua Wind.load_plug('copyq').show()"}) 35 | n({'ul', "lua require('nvim-autospace').format()", desc = "format current line"}) 36 | 37 | n({'f', 'lua require("spectre").open({is_insert_mode=true})'}) 38 | n({'rp', "viw:lua require('spectre').open_file_search()","search current file"}) 39 | v({'R', ":lua require('spectre').open_visual()", "open spectre"}) 40 | n({'R', "viw:lua require('spectre').open_visual()", "open spectre"}) 41 | n({'lt', ":LspTroubleOpen", "lsp open trouble"}) 42 | n({';v', 'lua require("spectre").open({cwd="~/.config/nvim"})', "find nvim config"}) 43 | 44 | n({'', 'lua require("Navigator").left()'}) 45 | n({'', 'lua require("Navigator").right()'}) 46 | n({'', 'lua require("Navigator").down()'}) 47 | n({'', 'lua require("Navigator").up()'}) 48 | -------------------------------------------------------------------------------- /snippets/sh.json: -------------------------------------------------------------------------------- 1 | { 2 | "bash": { 3 | "prefix": [ 4 | "bash", 5 | "#!", 6 | "shebang" 7 | ], 8 | "body": "${1|#!/bin/bash,#!/usr/bin/env bash|}\n", 9 | "description": [ 10 | "Option 1:\n", 11 | "#!/bin/bash\n", 12 | "Description: Shebang Bash executor.\n", 13 | "Option 2:\n", 14 | "#!/usr/bin/env bash\n", 15 | "Description: Shell searchs for the first match of bash in the $PATH environment variable.\n", 16 | "It can be useful if you aren't aware of the absolute path or don't want to search for it.\n" 17 | ] 18 | }, 19 | "echo": { 20 | "prefix": "echo", 21 | "body": "echo \"${0:message}\"", 22 | "description": "Echo a message." 23 | }, 24 | "read": { 25 | "prefix": "read", 26 | "body": "read -r ${0:VAR}", 27 | "description": "Read input of ${VAR}." 28 | }, 29 | "if": { 30 | "prefix": "if", 31 | "body": "if [[ ${0:condition} ]]; then\n\t${1}\nfi", 32 | "description": "An IF statement." 33 | }, 34 | "elseif": { 35 | "prefix": "elseif", 36 | "body": "elif [[ ${0:condition} ]]; then\n\t${1}", 37 | "description": "Add an elseif to an if statement." 38 | }, 39 | "else": { 40 | "prefix": "else", 41 | "body": "else\n\t${0:command}", 42 | "description": "else" 43 | }, 44 | "for_in": { 45 | "prefix": "for_in", 46 | "body": "for ${0:VAR} in $${1:LIST}\ndo\n\techo \"$${0:VAR}\"\ndone\n", 47 | "description": "for loop in list" 48 | }, 49 | "for_i": { 50 | "prefix": "for_i", 51 | "body": "for ((${0:i} = 0; ${0:i} < ${1:10}; ${0:i}++)); do\n\techo \"$${0:i}\"\ndone\n", 52 | "description": "An index-based iteration for loop." 53 | }, 54 | "while": { 55 | "prefix": "while", 56 | "body": "while [[ ${1:condition} ]]; do\n\t${0}\ndone\n", 57 | "description": "A while loop by condition." 58 | }, 59 | "until": { 60 | "prefix": "until", 61 | "body": "until [[ ${1:condition} ]]; do\n\t${0}\ndone\n", 62 | "description": "until loop by condition" 63 | }, 64 | "function": { 65 | "prefix": "function", 66 | "body": "${1:name} ()\n{\n\t${0}\n}", 67 | "description": [ 68 | "This defines a function named name.\n", 69 | "The reserved word function is optional.\n", 70 | "If the function reserved word is supplied, the parentheses are optional.\n", 71 | "1. Recommended way:\n", 72 | "name() {}\n", 73 | "2. C-like-way:\nfunction name [()] {}" 74 | ] 75 | }, 76 | "case": { 77 | "prefix": "case", 78 | "body": "case \"$${0:VAR}\" in\n\t${1:1}) echo 1\n\t;;\n\t${2:2|3}) echo 2 or 3\n\t;;\n\t*) echo default\n\t;;\nesac\n", 79 | "description": [ 80 | "case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac\n", 81 | "A case command first expands word, and tries to match it against each pattern in turn." 82 | ] 83 | }, 84 | "break": { 85 | "prefix": "break", 86 | "body": "break ${0}", 87 | "description": [ 88 | "The break command tells Bash to leave the loop straight away.\n", 89 | "Enter the break or break (n) where n=number of loops." 90 | ] 91 | }, 92 | "expr": { 93 | "prefix": "expr", 94 | "body": "expr ${0:1 + 1}", 95 | "description": "Calculate numbers with Bash." 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lua/wind/plug/windline/init.lua: -------------------------------------------------------------------------------- 1 | local windline = require('windline') 2 | local helper = require('windline.helpers') 3 | local comps = import('plug.windline.comps') 4 | 5 | local default = { 6 | filetypes = { 'default' }, 7 | active = { 8 | comps.vi_mode, 9 | comps.vi_mode_sep, 10 | comps.git_status, 11 | comps.lsp_diagnos, 12 | comps.search_count, 13 | comps.space, 14 | comps.file_name, 15 | comps.wave_left, 16 | comps.divider, 17 | comps.divider, 18 | comps.wave_right, 19 | comps.alert_mode, 20 | comps.lsp_status, 21 | comps.line_col, 22 | comps.sep_second_left_black, 23 | comps.progress, 24 | }, 25 | in_active = { 26 | comps.file_name_inactive, 27 | comps.divider, 28 | comps.divider, 29 | comps.line_col_inactive, 30 | comps.sep_second_left, 31 | comps.progress_inactive, 32 | }, 33 | } 34 | 35 | local explorer = { 36 | filetypes = { 'fern', 'NvimTree' , 'lir'}, 37 | active = { 38 | { '  ', { 'white', 'black' } }, 39 | { helper.separators.slant_right, { 'black', 'MiddleBg' } }, 40 | comps.divider, 41 | comps.explorer_name, 42 | comps.space, 43 | }, 44 | show_in_active = true, 45 | } 46 | 47 | local quickfix = { 48 | filetypes = { 'qf', 'Trouble' }, 49 | active = { 50 | { '🚦 Quickfix ', { 'white', 'black' } }, 51 | { helper.separators.slant_right, { 'black', 'black_light' } }, 52 | { 53 | function() return vim.fn.getqflist({title = 0}).title end, 54 | {'cyan', 'black_light'} 55 | }, 56 | { ' Total : %L ', { 'cyan', 'black_light' } }, 57 | { helper.separators.slant_right, { 'black_light', 'InactiveBg' } }, 58 | { ' ', { 'InactiveFg', 'InactiveBg' } }, 59 | comps.divider, 60 | { helper.separators.slant_right, { 'InactiveBg', 'black' } }, 61 | {'🧛 ',{'white', 'black'}} 62 | }, 63 | show_in_active = true, 64 | } 65 | 66 | local terminal = { 67 | filetypes = { 'toggleterm' }, 68 | active = { 69 | comps.terminal_mode, 70 | comps.terminal_name, 71 | comps.divider, 72 | comps.divider, 73 | comps.line_col_inactive, 74 | comps.sep_second_left, 75 | comps.progress_inactive, 76 | }, 77 | show_in_active = true, 78 | } 79 | 80 | windline.setup({ 81 | theme = require('windline.themes.wind'), 82 | colors_name = function(colors) 83 | 84 | colors.LeftFg = colors.black 85 | colors.LeftBg = colors.white 86 | 87 | colors.MiddleFg = colors.black 88 | colors.MiddleBg = colors.white_light 89 | 90 | colors.RightFg = colors.black 91 | colors.RightBg = colors.white 92 | 93 | colors.wavewhite = colors.white 94 | 95 | colors.waveleft1 = colors.MiddleBg 96 | colors.waveleft2 = colors.MiddleBg 97 | colors.waveleft3 = colors.MiddleBg 98 | colors.waveleft4 = colors.MiddleBg 99 | colors.waveleft5 = colors.MiddleBg 100 | 101 | colors.waveright1 = colors.MiddleBg 102 | colors.waveright2 = colors.MiddleBg 103 | colors.waveright3 = colors.MiddleBg 104 | colors.waveright4 = colors.MiddleBg 105 | colors.waveright5 = colors.MiddleBg 106 | return colors 107 | end, 108 | tabline={}, 109 | statuslines = { 110 | default, 111 | explorer, 112 | quickfix, 113 | terminal 114 | }, 115 | }) 116 | -------------------------------------------------------------------------------- /ftplugin/markdown.vim: -------------------------------------------------------------------------------- 1 | 2 | if exists("b:md_current_syntax") | finish | endif 3 | let b:md_current_syntax=1 4 | let g:my_list_task_progress= ['TODO', 'FIXME', 'PROGRESS', 'CANCELED', 'DONE' ] 5 | setlocal cole=1 6 | 7 | " toggle to do in markdown 8 | function! MyTodoToggle() 9 | let l:line=getline('.') 10 | if match(l:line ,'\[ \]')!=-1 11 | execute 's/\[ \]/\[x\]/' 12 | execute "\'\'" 13 | elseif match(l:line,'\[x\]')!=-1 14 | execute 's/\[x\]/\[ \]/' 15 | execute "\'\'" 16 | elseif match(l:line,'^ *\* [^\[]')!=-1 17 | execute 's/^\( *\)\* \([^\[]\)/\1* [ ] \2/' 18 | execute "\'\'" 19 | endif 20 | endfunction 21 | 22 | function! MyTableNewRow() 23 | let l:line=getline('.') 24 | if match(l:line,'^\s\=|')!=-1 25 | let l:text=substitute(l:line,'[^|]',' ','g') 26 | let l:text=substitute(l:text,' ','','g') 27 | let l:text=substitute(l:text,'|','| ','g') 28 | normal o 29 | execute "normal! i".l:text 30 | call feedkeys("0lli") 31 | endif 32 | endfunction 33 | 34 | 35 | 36 | 37 | function! FixVimMarkdown() abort 38 | 39 | nnoremap go :Toc 40 | " nnoremap gtt :call MyListTaskProgress() 41 | nnoremap gtc :call MyTodoToggle() 42 | nnoremap t :call MyTodoToggle() 43 | nnoremap gtn :call MyTableNewRow() 44 | nnoremap gtr :Toc 45 | nnoremap gtp :call MyPandocPdf() 46 | 47 | 48 | if exists("g:wind_use_note") 49 | hi htmlH1 ctermfg=88 guifg=#9d0006 ctermbg=None gui=bold term=bold cterm=bold 50 | hi htmlH2 ctermfg=106 guifg=#fb4934 ctermbg=None gui=bold 51 | hi htmlH3 ctermfg=166 guifg=#98971a ctermbg=None gui=bold 52 | hi htmlH4 ctermfg=109 guifg=#458588 ctermbg=None gui=bold 53 | hi htmlH5 ctermfg=124 guifg=#b16286 ctermbg=None gui=bold 54 | hi mkdCodeStart ctermfg=239 guifg=#9E9E9E ctermbg=None gui=bold 55 | hi mkdCodeEnd ctermfg=239 guifg=#9E9E9E ctermbg=None gui=bold 56 | hi mkdCode ctermfg=88 guifg=#427b58 ctermbg=None cterm=bold 57 | endif 58 | 59 | syn match mkdTodo /\vTODO/ containedin=mkdListItemLine,mkdItalic 60 | syn match mkdFixMe /\vFIXME/ containedin=mkdListItemLine,mkdItalic 61 | syn match mkdProgress /\vPROGRESS/ containedin=mkdListItemLine,mkdItalic 62 | syn match mkdCanceled /\vCANCELED/ containedin=mkdListItemLine,mkdItalic 63 | syn match mkdDone /\vDONE/ containedin=mkdListItemLine,mkdItalic 64 | 65 | hi mkdTodo ctermfg=106 guifg=#fe8019 gui=bold 66 | hi mkdFixMe ctermfg=106 guifg=#cc241d gui=bold 67 | hi mkdProgress ctermfg=106 guifg=#83a598 gui=bold 68 | hi mkdCancled ctermfg=106 guifg=#fabd2f gui=bold 69 | hi mkdDone ctermfg=106 guifg=#00C853 gui=bold 70 | 71 | syntax match mkdCheckBox /\[\ \]/ conceal cchar= containedin=mkdListItemLine,mkdItalic 72 | syntax match mkdCheckBox /\[x\]/ conceal cchar= containedin=mkdListItemLine,mkdItalic 73 | " Plugin indentline will override it 74 | hi Conceal guifg=#427b58 ctermfg=88 75 | hi htmlItalic gui=italic 76 | 77 | setlocal shiftwidth=2 78 | setlocal formatoptions=tron 79 | " it will allow auto insert *+- in comment after newline 80 | setlocal comments=b:*,b:+,b:- 81 | 82 | endfunction 83 | 84 | function! MyPandocPdf() 85 | execute "!pandoc ". expand("%:p") ." -o " .expand("%:p:s?\.md$?\.pdf?")." --from markdown --template eisvogel --listings" 86 | endfunction 87 | 88 | " fix markdown table algin 89 | function! FixMdTable()abort 90 | let l:line=getline('.') 91 | if match(l:line ,'^|')!=-1 92 | execute ":TableFormat" 93 | endif 94 | endfunction 95 | 96 | -------------------------------------------------------------------------------- /plugin/wind.vim: -------------------------------------------------------------------------------- 1 | function! wind#open() abort 2 | " Linux/BSD 3 | if executable('xdg-open') 4 | return 'xdg-open' 5 | endif 6 | " MacOS 7 | if executable('open') 8 | return 'open' 9 | endif 10 | " Windows 11 | return 'explorer' 12 | endfunction 13 | 14 | "check current cursor is end of line" 15 | function! wind#IsEndOfLine() abort 16 | let l:allowWordReg = '[a-zA-Z0-9]' 17 | let l:line = getline('.') 18 | let l:pos = getcurpos() 19 | let l:charIndex = l:pos[2] 20 | let l:char="" 21 | while l:charIndex 0 34 | let l:count = l:count * v:prevcount 35 | endif 36 | let pos = getcurpos()[1] 37 | execute "normal! gv" 38 | let start = getpos("'<")[1] 39 | let end = getpos("'>")[1] 40 | if l:count == 1 41 | let resultline = end + 1 42 | elseif l:count ==-1 43 | let resultline = start - 2 44 | elseif l:count>0 45 | let resultline = pos + l:count 46 | else 47 | let resultline = pos + l:count-1 48 | endif 49 | try 50 | execute "normal! :m ".resultline."\gv" 51 | catch 52 | endtry 53 | endfunction 54 | 55 | 56 | function! wind#QfClose() abort 57 | for i in range(1, winnr('$')) 58 | let bnum = winbufnr(i) 59 | if getbufvar(bnum, '&buftype') == 'quickfix' 60 | cclose 61 | lclose 62 | return 1 63 | endif 64 | endfor 65 | return 0 66 | endfunction 67 | 68 | " save and quit use it with 'set confim' setting 69 | " auto close quick fix first 70 | function! wind#SuperQuit() abort 71 | if match(expand("%"), "^octo\:\/")>-1 72 | execute ":bd" 73 | return 74 | endif 75 | if match(expand("%"), "^fugitive\:\/\/")>-1 || match(expand("%"), "COMMIT_EDITMSG$")>-1 76 | call wind#QfClose() 77 | execute ":bd" 78 | return 79 | endif 80 | if wind#QfClose() == 1 81 | return 82 | end 83 | let l:blist = getbufinfo({'bufloaded': 1, 'buflisted': 1}) 84 | " check to vim command mode 85 | if &buftype == 'nofile' || &buftype =='help' 86 | if &filetype =='vim' 87 | execute ":close" 88 | else 89 | execute ":bd" 90 | endif 91 | return 92 | end 93 | if &buftype == 'terminal' || &filetype =~? '^fern' 94 | execute ":q" 95 | return 96 | endif 97 | 98 | let l:bufnr = bufnr('%') 99 | " neu hien thi o 1 buffer khac thi close 100 | let l:windows = win_findbuf(l:bufnr) 101 | try 102 | if len(l:windows)>1 103 | close 104 | return 105 | end 106 | catch 107 | return 108 | endtry 109 | " check is the last buffer open then close vim 110 | let l:bufCount = 0 111 | for buf in getbufinfo({'buflisted':1}) 112 | if get(g:, 'wind_auto_close', 0) == 1 113 | if len(buf.name)>2 && buf.changed == 1 114 | let l:bufCount = l:bufCount + 1 115 | endif 116 | else 117 | if len(buf.name)>2 || buf.changed == 1 118 | let l:bufCount = l:bufCount + 1 119 | endif 120 | endif 121 | endfor 122 | if l:bufCount >= 1 123 | execute ":bd" 124 | else 125 | execute ":q" 126 | endif 127 | endfunction 128 | 129 | " Toggle quickfix window. 130 | function! wind#QfToggle() 131 | if wind#QfClose() == 1| return| end 132 | copen 133 | endfunction 134 | 135 | 136 | augroup resCur 137 | autocmd! 138 | au BufReadPost * 139 | \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' 140 | \ | exe "normal! g`\"" 141 | \ | exe "normal! zz" 142 | \ | endif 143 | augroup END 144 | -------------------------------------------------------------------------------- /lua/wind/plug/copyq.lua: -------------------------------------------------------------------------------- 1 | -- use Telescopt to get text from copyq 2 | -- 3 | local actions = require('telescope.actions') 4 | local action_state = require('telescope.actions.state') 5 | local finders = require('telescope.finders') 6 | local pickers = require('telescope.pickers') 7 | local sorters = require('telescope.sorters') 8 | local themes=require('telescope.themes') 9 | 10 | local M={} 11 | local popup = require('popup') 12 | local conf = require('telescope.config').values 13 | local utils = require('telescope.utils') 14 | local log = require('telescope.log') 15 | 16 | M.msgLoadingPopup = function(msg, cmd, complete_fn) 17 | local row = math.floor((vim.o.lines-5) / 2) 18 | local width = math.floor(vim.o.columns / 1.5) 19 | local col = math.floor((vim.o.columns - width) / 2) 20 | for _ = 1, (width-#msg)/2, 1 do 21 | msg = " "..msg 22 | end 23 | local prompt_win, prompt_opts = popup.create(msg, { 24 | border ={}, 25 | borderchars = conf.borderchars , 26 | height = 5, 27 | col = col, 28 | line = row, 29 | width = width, 30 | }) 31 | vim.api.nvim_win_set_option(prompt_win, 'winhl', 'Normal:TelescopeNormal') 32 | vim.api.nvim_win_set_option(prompt_win, 'winblend', 0) 33 | local prompt_border_win = prompt_opts.border and prompt_opts.border.win_id 34 | if prompt_border_win then vim.api.nvim_win_set_option(prompt_border_win, 'winhl', 'Normal:TelescopePromptBorder') end 35 | vim.defer_fn(vim.schedule_wrap(function() 36 | local results = utils.get_os_command_output(cmd) 37 | if not pcall(vim.api.nvim_win_close, prompt_win, true) then 38 | log.trace("Unable to close window: ", "copyq", "/", prompt_win) 39 | end 40 | complete_fn(results) 41 | end),10) 42 | end 43 | 44 | M.show = function() 45 | local max=100 46 | local opts = {} 47 | local separator=[[|||]] 48 | local cmd = {'copyq', 'separator', "\n"..separator, 'read'} 49 | for i = 0, max, 1 do 50 | table.insert(cmd, "" .. i) 51 | end 52 | M.msgLoadingPopup("Loading copyq ", cmd, function (results) 53 | local list = {} 54 | local item = { 55 | key = '', 56 | display = '', 57 | line = 1, 58 | text = '' 59 | } 60 | for _, value in pairs(results) do 61 | if string.match(value, "^" .. separator) ~= nil then 62 | if string.len(item.key) > 1 then 63 | table.insert(list, item) 64 | end 65 | local text=value:sub(#separator + 1, string.len(value) ); 66 | item = { 67 | line = 0, 68 | display = text, 69 | key = text, 70 | text = text , 71 | } 72 | else 73 | if item.key == '' and string.len(value) > 2 then 74 | item.key = value 75 | item.display = value 76 | item.line = 0 77 | end 78 | item.line = item.line + 1 79 | if item.line > 1 then 80 | item.display = item.key .. string.format(" [[%s lines]]", item.line) 81 | end 82 | item.text = item.text .. "\n" .. value 83 | end 84 | end 85 | table.insert(list, item) 86 | opts = themes.get_dropdown(opts) 87 | opts.previewer = false 88 | opts.width = nil 89 | pickers.new(opts,{ 90 | prompt_title = 'Copyq', 91 | finder = finders.new_table { 92 | results = list, 93 | entry_maker = M.make_entry(), 94 | }, 95 | sorter = sorters.get_generic_fuzzy_sorter(), 96 | attach_mappings = function() 97 | actions.select_default:replace(function (prompt_bufnr) 98 | local entry = action_state.get_selected_entry() 99 | actions.close(prompt_bufnr) 100 | if vim.api.nvim_buf_get_option(vim.api.nvim_get_current_buf(), "modifiable") then 101 | lines = {} 102 | for s in entry.value:gmatch("[^\r\n]+") do 103 | table.insert(lines, s) 104 | end 105 | vim.api.nvim_put(lines,'c',true ,true) 106 | end 107 | end 108 | ) 109 | return true 110 | end, 111 | }):find() 112 | end) 113 | end 114 | M.make_entry=function() 115 | return function(entry) 116 | return{ 117 | valid = true, 118 | value = entry.text, 119 | ordinal = entry.key, 120 | display = entry.display 121 | } 122 | end 123 | end 124 | 125 | return M 126 | -------------------------------------------------------------------------------- /lua/wind/core/wind.lua: -------------------------------------------------------------------------------- 1 | -- global utils 2 | local M = {} 3 | _G.Wind = _G.Wind or M 4 | M.is_dev = false 5 | M.root='wind' 6 | M.func = {} -- global func for keymap 7 | M.state = {}-- global state 8 | local home = os.getenv('HOME') 9 | local path_sep = M.is_windows and '\\' or '/' 10 | local os_name = vim.loop.os_uname().sysname 11 | vim.g.wind_os_name = os_name 12 | 13 | local function load_variables () 14 | M.is_mac = os_name == 'Darwin' 15 | M.is_linux = os_name == 'Linux' 16 | M.is_windows = os_name == 'Windows' 17 | M.vim_path = vim.fn.stdpath('config') 18 | M.cache_dir = home .. path_sep .. '.vim' .. path_sep .. '.cache' .. path_sep 19 | M.path_sep = path_sep 20 | M.home = home 21 | end 22 | 23 | M.check_big_file = function() 24 | local big_file_size = 100 25 | local fname = vim.fn.expand('%:p:f') 26 | if fname then 27 | local fsize = vim.fn.getfsize(fname) or 1 28 | if fsize ==-2 or fsize > big_file_size * 1024 then 29 | Wind.state.is_open_big_file = true 30 | return true 31 | end 32 | end 33 | return false 34 | end 35 | -- load custom lsp 36 | M.load_lsp = function (langs) 37 | if type(langs) == 'string' then langs = {langs} end 38 | for _, lang in pairs(langs) do 39 | Wind.load_plug('lsp.lsp').load_lsp(lang) 40 | end 41 | end 42 | 43 | M.load_theme = function(theme_name) 44 | if vim.g.theme_name == theme_name then return end 45 | vim.g.theme_name = theme_name 46 | import('general.setting').load_theme(theme_name, true) 47 | end 48 | 49 | M.load_plug = function (plug) 50 | if string.match(plug, '%.vim$') then 51 | import(string.format('%s/plug/%s', Wind.vim_path, plug)) 52 | else 53 | return import('plug.' .. plug) 54 | end 55 | end 56 | 57 | -- https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/reload.lua 58 | local function reload_module(module_name, starts_with_only) 59 | -- TODO: Might need to handle cpath / compiled lua packages? Not sure. 60 | local matcher 61 | if not starts_with_only then 62 | matcher = function(pack) 63 | return string.find(pack, module_name, 1, true) 64 | end 65 | else 66 | matcher = function(pack) 67 | return string.find(pack, '^' .. module_name) 68 | end 69 | end 70 | 71 | for pack, _ in pairs(package.loaded) do 72 | if matcher(pack) then 73 | package.loaded[pack] = nil 74 | end 75 | end 76 | end 77 | 78 | _G.P = function (a) 79 | print(vim.inspect(a)) 80 | end 81 | 82 | _G.R = function(name) 83 | reload_module(name) 84 | return require(name) 85 | end 86 | 87 | M.import_vim = function(path) 88 | vim.cmd("source" .. path ) 89 | end 90 | 91 | M.import_lua = function(path) 92 | vim.cmd("luafile ".. path) 93 | end 94 | 95 | _G.import = function (path) 96 | if string.match(path, '%.vim$') then 97 | local err, detail = pcall(M.import_vim, path) 98 | if not err then 99 | print("Import vim error: " .. path) 100 | vim.api.nvim_err_writeln(vim.inspect(detail)) 101 | end 102 | return 103 | end 104 | if string.match(path, '%.lua$') then 105 | local err, detail = pcall(M.import_lua, path) 106 | if not err then 107 | print("Import lua error: " .. path) 108 | vim.api.nvim_err_writeln(vim.inspect(detail)) 109 | end 110 | return 111 | end 112 | 113 | path = string.format("%s.%s", M.root, path) 114 | 115 | if M.is_dev then 116 | return R(path) 117 | else 118 | local check, detail = pcall(require,path) 119 | if check then 120 | return detail 121 | else 122 | print("Import module error: " .. path) 123 | vim.api.nvim_err_writeln(debug.traceback(detail)) 124 | -- vim.api.nvim_err_writeln(detail) 125 | end 126 | end 127 | end 128 | 129 | 130 | M.live_reload = function(name) 131 | if _G._require == nil then 132 | print('live reload : ' .. name) 133 | _G.__is_log = true 134 | _G._require = require 135 | _G.require = function(path) 136 | if string.find(path,string.format('^%s[^_]*$',name)) ~= nil then 137 | reload_module(path) 138 | end 139 | return _G._require(path) 140 | end 141 | end 142 | end 143 | 144 | load_variables() 145 | 146 | return M 147 | -------------------------------------------------------------------------------- /lua/wind/plugins.lua: -------------------------------------------------------------------------------- 1 | -- vim: foldmethod=marker sw=2 formatoptions-=o foldlevel=0 2 | 3 | if vim.g.wind_use_plugin == 0 then return end 4 | 5 | local plug = import('core.plug') 6 | local Plug = plug.Plug 7 | 8 | 9 | -- some config for plugin if it use with packadd 10 | Wind.load_plug('_start') 11 | 12 | -- Basic: {{{ 13 | Plug 'nvim-lua/popup.nvim' 14 | Plug 'nvim-lua/plenary.nvim' 15 | Plug 'editorconfig/editorconfig-vim' 16 | Plug 'numToStr/Navigator.nvim' 17 | Plug {'windwp/windline.nvim', config = 'windline'} 18 | Plug {'windwp/nvim-projectconfig' , config = 'project-config'} 19 | ---}}} 20 | 21 | 22 | -- Git: {{{ 23 | Plug {'tpope/vim-fugitive' , config = 'gitopen.vim'} 24 | Plug {'rhysd/git-messenger.vim' , on = 'GitMessenger'} 25 | Plug {'junegunn/gv.vim' , on = 'GV' ,} 26 | Plug 'rhysd/conflict-marker.vim' 27 | Plug {'lewis6991/gitsigns.nvim', config = 'gitsigns'} 28 | -- }}} 29 | 30 | -- Lsp: {{{ 31 | 32 | Plug {'neovim/nvim-lspconfig', config = 'lsp.setup'} 33 | 34 | Plug {'hrsh7th/nvim-compe', config = 'compe'} 35 | Plug {'hrsh7th/vim-vsnip', event = "InsertEnter"} 36 | Plug {'hrsh7th/vim-vsnip-integ', event = "InsertEnter"} 37 | Plug {'mhartington/formatter.nvim', config = 'formatter' , key = "f"} 38 | 39 | -- }}} 40 | -- 41 | -- Telescope:{{{ 42 | Plug {'nvim-telescope/telescope.nvim', config = 'telescope'} 43 | Plug 'nvim-telescope/telescope-fzy-native.nvim' 44 | Plug 'nvim-telescope/telescope-github.nvim' 45 | Plug 'nvim-telescope/telescope-media-files.nvim' 46 | -- }}} 47 | 48 | -- Treesitter: {{{ 49 | local use_ts = vim.g.wind_use_treesitter == 1 50 | 51 | Plug {'nvim-treesitter/nvim-treesitter', config = 'treesitter', cond = use_ts} 52 | Plug {'nvim-treesitter/playground', on = 'TSPlaygroundToggle', cond = use_ts} 53 | Plug {'windwp/nvim-ts-autotag', cond = use_ts} 54 | 55 | -- }}} 56 | 57 | -- Theme: {{{ 58 | 59 | Plug 'windwp/wind-colors' 60 | Plug {'morhetz/gruvbox', opt = false} 61 | -- }}} 62 | 63 | -- File: {{{ 64 | local use_icon = vim.g.wind_use_icon == 1 65 | Plug {'vifm/vifm.vim', on = 'Vifm', } 66 | Plug {'lambdalisue/fern.vim', config = 'fern.vim', key = {"", "F"}} 67 | Plug {'windwp/fern-renderer-nerdfont.vim', branch = 'devicon', cond = use_icon, manual = true } 68 | Plug {'lambdalisue/glyph-palette.vim', cond = use_icon, manual = true} 69 | 70 | -- Plug {'tamago324/lir.nvim', config = 'lir'} 71 | Plug {'kyazdani42/nvim-web-devicons', config = 'web-devicons', cond = use_icon} 72 | -- }}} 73 | 74 | 75 | -- statusline {{{ 76 | 77 | Plug {'vimpostor/vim-tpipeline', cond = vim.g.wind_tmux_line == 1} 78 | --}}} 79 | 80 | 81 | -- Filetype {{{ 82 | Plug {'neoclide/jsonc.vim' , ft = 'json'} 83 | Plug {'plasticboy/vim-markdown' , ft = 'markdown'} 84 | Plug {'leafOfTree/vim-svelte-plugin' , ft = 'svelte'} 85 | Plug {'fatih/vim-go' , ft = 'go'} 86 | -- }}} 87 | 88 | -- Others: {{{ 89 | 90 | Plug {'windwp/nvim-autopairs', config = 'autopairs', event = "InsertEnter"} 91 | Plug {'windwp/nvim-autospace', event = "BufRead"} 92 | Plug {'windwp/nvim-spectre', config = 'spectre'} 93 | Plug {'ojroques/vim-oscyank', config = 'oscyank', on = "OSCYank"} 94 | Plug {'mizlan/iswap.nvim', config = 'iswap', on = 'ISwapWith'} 95 | Plug 'tpope/vim-commentary' 96 | Plug 'tpope/vim-repeat' 97 | 98 | Plug 'norcalli/nvim-colorizer.lua' 99 | Plug {'AndrewRadev/switch.vim', on = 'Switch'} -- toggle between true or false 100 | Plug {'voldikss/vim-floaterm', before = 'vim-floaterm.vim', on = "FloatermToggle"} 101 | Plug {'mg979/vim-visual-multi', before = 'vim-visual-multi.vim', key = ""} 102 | Plug {'skywind3000/asyncrun.vim', on="AsyncRun" } 103 | Plug {'pwntester/octo.nvim' , config = 'octo' , on = "Octo"} 104 | Plug {'folke/lsp-trouble.nvim', config = 'lsp-trouble' , on = 'LspTroubleOpen'} 105 | Plug {'sindrets/diffview.nvim', on = 'DiffviewOpen'} 106 | Plug {'folke/which-key.nvim', config = 'which-key'} 107 | 108 | Plug 'godlygeek/tabular' --" Markdown Tables 109 | Plug {'mbbill/undotree', on="UndotreeShow"} --" undo tree 110 | Plug 'djoshea/vim-autoread' --" auto update after save outside vim 111 | Plug {'machakann/vim-sandwich', event = "BufRead"} 112 | Plug 'obxhdx/vim-auto-highlight' --" highlight current world 113 | 114 | Plug {'lukas-reineke/indent-blankline.nvim', cond = vim.g.wind_use_indent == 1, config = "indent-blankline"} 115 | -- better match pairs and it can disable on insert mode 116 | Plug {'andymass/vim-matchup', config = 'matchup'} 117 | Plug {'hrsh7th/vim-eft', config = 'eft'} -- hight light character on ft key 118 | -- Plug {'dstein64/vim-startuptime' } 119 | 120 | -- }}} 121 | 122 | 123 | plug.load_config() 124 | 125 | Wind.load_plug('_end') 126 | -------------------------------------------------------------------------------- /plug/fern.vim: -------------------------------------------------------------------------------- 1 | " https://github.com/lambdalisue/fern.vim/blob/master/doc/fern.txt 2 | " Disable netrw. 3 | packadd fern-renderer-nerdfont.vim 4 | packadd glyph-palette.vim 5 | 6 | let g:fern#renderer = "nerdfont" 7 | augroup my-fern-hijack 8 | autocmd! 9 | autocmd BufEnter * ++nested call s:hijack_directory() 10 | augroup END 11 | 12 | function! s:hijack_directory() abort 13 | let path = expand('%:p') 14 | if !isdirectory(path) 15 | return 16 | endif 17 | bwipeout % 18 | execute printf('Fern %s', fnameescape(path)) 19 | endfunction 20 | 21 | " Custom settings and mappings. 22 | let g:fern#disable_default_mappings = 1 23 | let g:fern#default_hidden=1 24 | let g:fern#autoclose=1 25 | let g:fern#hide_cursor=1 26 | 27 | let g:fern#keepalt_on_edit=1 28 | let g:fern#disable_drawer_auto_winfixwidth=0 29 | 30 | noremap F :let g:fern#autoclose=0:let g:fern#open_buffer=bufnr('%'):keepalt Fern %:h -reveal=%:p 31 | noremap :let g:fern#autoclose=1 Fern . -drawer -reveal=% -toggle = 32 | 33 | function! s:closeFern(target) abort 34 | if a:target == "split" 35 | execute "normal \(fern-action-open:split)" 36 | elseif a:target== "vsplit" 37 | execute "normal \(fern-action-open:vsplit)" 38 | else 39 | execute "normal \(fern-action-open)" 40 | endif 41 | if g:fern#autoclose ==0 42 | execute "FernDo close -drawer -stay" 43 | endif 44 | endfunction 45 | 46 | function! s:DownloadFile() abort 47 | execute "normal \(fern-action-yank:path)" 48 | let l:text=getreg('+') 49 | echom " . l:text: ".l:text 50 | execute "AsyncRunSilent cpdragon " . l:text 51 | endfunction 52 | 53 | function! s:quitFern() abort 54 | execute ":buffer " . g:fern#open_buffer 55 | endfunction 56 | 57 | function! FernInit() abort 58 | nmap (fern-my-open-and-close) :call closeFern("") 59 | nmap (fern-my-open-and-close:split) :call closeFern("split") 60 | nmap (fern-my-open-and-close:vsplit) :call closeFern("vsplit") 61 | nmap 62 | \ (fern-my-open-expand-collapse) 63 | \ fern#smart#leaf( 64 | \ "\(fern-my-open-and-close)", 65 | \ "\(fern-action-expand)", 66 | \ "\(fern-action-collapse)", 67 | \ ) 68 | nmap l (fern-my-open-expand-collapse) 69 | nmap h (fern-action-collapse) 70 | nmap (fern-my-open-expand-collapse) 71 | nmap <2-LeftMouse> (fern-my-open-expand-collapse) 72 | nmap u 73 | nmap n (fern-action-new-path) 74 | " nnoremap n n 75 | nmap dd (fern-action-remove) 76 | nmap yn (fern-action-yank:label) 77 | nmap yf (fern-action-yank:path) 78 | 79 | nmap cm (fern-action-clipboard-move) 80 | nmap cp (fern-action-clipboard-paste) 81 | nmap cc (fern-action-clipboard-copy) 82 | nmap yy (fern-action-clipboard-copy) 83 | nmap cx (fern-action-mark:clear) 84 | nmap dr :call DownloadFile() 85 | nmap M (fern-action-rename) 86 | nmap cw (fern-action-rename:split) 87 | " nmap h (fern-action-hidden:toggle) 88 | nmap r (fern-action-reload) 89 | nmap t (fern-action-mark)j 90 | nmap b (fern-my-open-and-close:split) 91 | nmap (fern-my-open-and-close:vsplit) 92 | nmap < (fern-action-leave) 93 | nmap > (fern-action-enter) 94 | nmap z (fern-action-zoom) 95 | if g:fern#autoclose ==0 96 | nmap F :call quitFern() 97 | nmap gq :call quitFern() 98 | else 99 | nmap F :q 100 | endif 101 | setlocal foldmethod=manual 102 | 103 | if get(g:,'wind_use_icon', 0) == 1 104 | highlight GlypPallteSelect guifg=#9d0006 105 | let g:glyph_palette#defaults#palette['GlyphPaletteDirectory']=['', '' ] 106 | let g:glyph_palette#defaults#palette['GlypPallteSelect']=[''] 107 | call glyph_palette#apply() 108 | endif 109 | endfunction 110 | 111 | augroup FernGroup 112 | autocmd! 113 | autocmd FileType fern call FernInit() 114 | augroup END 115 | 116 | "==================================" 117 | " Icon glyph " 118 | "==================================" 119 | 120 | augroup fern-glyph-palette 121 | autocmd! 122 | autocmd FileType fern-replacer setlocal foldmethod=manual | nnoremap :w 123 | autocmd FileType fern setlocal norelativenumber | setlocal nonumber | setlocal signcolumn=no 124 | augroup END 125 | 126 | -------------------------------------------------------------------------------- /lua/wind/core/utils.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.map(mode, lhs, rhs, opts) 4 | local options = {noremap = true, silent = true} 5 | if opts then 6 | options = vim.tbl_extend("force", options, opts) 7 | end 8 | vim.api.nvim_set_keymap(mode, lhs, rhs, options) 9 | end 10 | function M.mapBuf(buf, mode, lhs, rhs, opts) 11 | local options = {noremap = true, silent = true} 12 | if opts then 13 | options = vim.tbl_extend("force", options, opts) end 14 | vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options) 15 | end 16 | 17 | -- Usage: 18 | -- highlight(Cursor, { fg = bg_dark, bg = yellow }) 19 | function M.highlight(group, styles) 20 | local s = vim.tbl_extend('keep', styles, { gui = 'NONE', sp = 'NONE', fg = 'NONE', bg = 'NONE' }) 21 | vim.cmd('highlight! '..group..' gui='..s.gui..' guisp='..s.sp..' guifg='..s.fg..' guibg='..s.bg) 22 | end 23 | 24 | -- Usage: 25 | -- highlight({ 26 | -- CursorLine = { bg = bg }, 27 | -- Cursor = { fg = bg_dark, bg = yellow } 28 | -- }) 29 | function M.highlights(hi_table) 30 | for group, styles in pairs(hi_table) do 31 | M.highlight(group, styles) 32 | end 33 | end 34 | 35 | function M.hiLink(src, dest) 36 | vim.cmd('highlight link '..src..' '..dest) 37 | end 38 | 39 | function M.hiLinks(hi_table) 40 | for src, dest in pairs(hi_table) do 41 | M.hiLink(src, dest) 42 | end 43 | end 44 | 45 | 46 | function M.autocmd(event, triggers, operations) 47 | local cmd = string.format("autocmd %s %s %s", event, triggers, operations) 48 | vim.cmd(cmd) 49 | end 50 | 51 | function M.abbs(wrong_str, correct_str) 52 | vim.cmd(string.format("%sabbrev %s %s", 'i', wrong_str, correct_str)) 53 | end 54 | 55 | function M.cabbs(wrong_str, correct_str ) 56 | vim.cmd(string.format("%sabbrev %s %s", 'c', wrong_str, correct_str)) 57 | end 58 | 59 | function M.buf_get_full_text(bufnr) 60 | local text = table.concat(vim.api.nvim_buf_get_lines(bufnr, 0, -1, true), '\n') 61 | if vim.api.nvim_buf_get_option(bufnr, 'eol') then 62 | text = text .. '\n' 63 | end 64 | return text 65 | end 66 | 67 | 68 | -- get visual selection text 69 | --https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript 70 | function M.get_visual_selection() 71 | local start_pos = vim.api.nvim_buf_get_mark(0, '<') 72 | local end_pos = vim.api.nvim_buf_get_mark(0, '>') 73 | local lines = vim.fn.getline(start_pos[1], end_pos[1]) 74 | -- add when only select in 1 line 75 | local plusEnd = 0 76 | local plusStart = 1 77 | if #lines == 0 then 78 | return '' 79 | elseif #lines ==1 then 80 | plusEnd = 1 81 | plusStart =1 82 | end 83 | lines[#lines] = string.sub(lines[#lines], 0 , end_pos[2]+ plusEnd) 84 | lines[1] = string.sub(lines[1], start_pos[2] + plusStart , string.len(lines[1])) 85 | local query=table.concat(lines,'') 86 | return query 87 | end 88 | 89 | function M.check_backspace () 90 | local col = vim.fn.col('.') - 1 91 | local char = vim.fn.getline('.'):sub(col, col) 92 | if col == 0 or char:match("[%s%'\\\"]") then 93 | return true 94 | else 95 | return false 96 | end 97 | end 98 | 99 | 100 | function M.CodeFormat() 101 | local listFile = {'javascript' , 'typescript' , 'typescriptreact' , 'css' , 'html' , 'scss' , 'md'} 102 | for _,v in pairs(listFile) do 103 | if v == vim.bo.filetype then 104 | vim.cmd("Format") 105 | return 106 | end 107 | end 108 | vim.lsp.buf.formatting() 109 | end 110 | 111 | 112 | 113 | -- check current cursor is on end line 114 | function M.is_end_of_line() 115 | local line = vim.api.nvim_get_current_line() 116 | local pos = vim.fn.getpos('.') 117 | local last = pos[3] 118 | for i = last, string.len(line), 1 do 119 | local char=line:sub(i,i) 120 | if not string.match(char,"%w") then 121 | return false 122 | end 123 | end 124 | return true 125 | end 126 | -- automatic trim new line when use yy on 1 line 127 | -- and copy it in visual mode 128 | function M.trimNewLine() 129 | local register = '+' 130 | local clipboard = vim.fn.getreg(register) 131 | local _, count = clipboard:gsub('\n','\n') 132 | if count == 1 then 133 | clipboard = clipboard:gsub("\n", "") 134 | vim.fn.setreg(register,clipboard) 135 | end 136 | if M.is_end_of_line() then 137 | return vim.keymap.t[["1dpgv]] 138 | else 139 | return vim.keymap.t[["1dPgv]] 140 | end 141 | end 142 | 143 | local _, ts_utils = pcall(require, 'nvim-treesitter.ts_utils') 144 | 145 | -- check is inside in specific treesitter node 146 | -- M.check_ts_node('^jsx') 147 | function M.check_ts_node(pattern) 148 | if pattern == nil then return false end 149 | local cur_node = ts_utils.get_node_at_cursor() 150 | while cur_node ~= nil do 151 | local node_name = cur_node:type() 152 | if node_name ~= nil and string.match(node_name, pattern) then 153 | return true 154 | else 155 | cur_node = cur_node:parent() 156 | end 157 | end 158 | return false 159 | end 160 | 161 | --- chekc vim global value is exist if it exist skip set 162 | function M.set_vim_global(opts, check) 163 | for k,v in pairs(opts) do 164 | if check and vim.g[k] == nil then 165 | vim.g[k] = v 166 | else 167 | vim.g.k=v 168 | end 169 | end 170 | end 171 | 172 | Wind.trimNewLine=M.trimNewLine 173 | 174 | return M 175 | -------------------------------------------------------------------------------- /lua/wind/plug/which-key.lua: -------------------------------------------------------------------------------- 1 | 2 | local wk = require('which-key') 3 | 4 | wk.setup { 5 | triggers = {"", 'g'}, 6 | plugins = { 7 | marks = false, -- shows a list of your marks on ' and ` 8 | registers = false, -- shows your registers on " in NORMAL or in INSERT mode 9 | -- the presets plugin, adds help for a bunch of default keybindings in Neovim 10 | -- No actual key bindings are created 11 | presets = false 12 | }, 13 | } 14 | wk.register({ 15 | ['.'] = 'get vim syntax', 16 | r = { 17 | name = '+replace' , 18 | r = 'simple replace' , 19 | w = 'replace current word' , 20 | v = 'replace in visual text only' 21 | }, 22 | e = { 23 | name = "+edit file", 24 | a = 'Algin' , 25 | t = 'table format' , 26 | }, 27 | u = { 28 | name = "+utility", 29 | i = 'toggle system keyboard' , 30 | k = 'toggle vim keyboard' , 31 | d = 'diff 2 panel ' , 32 | l = 'format line' , 33 | f = {':Vifm' , 'vifm ' } , 34 | u = {':UndotreeShow' , 'undotreeShow' } , 35 | w = {[[:%s/\s\+$//e]] , 'trim whitespace' } , 36 | t = 'get test cmd' , 37 | b = {':call MyBoxToilet()' , 'create term box' } , 38 | ['m'] = {':MyRedir messages' , 'log meesage' } , 39 | ['='] = {':call MyCreateLine("=")' , 'create line' } , 40 | ['.'] = {':call MyBackgroundToggle()' , 'toggle Background' } , 41 | }, 42 | c = { 43 | name = '+current action' 44 | }, 45 | l = { name="+lsp" }, 46 | j = { name = "+jump" }, 47 | g = { 48 | name="+git", 49 | a = {':Git add %' , 'add current' } , 50 | A = {':Git add .' , 'add all' } , 51 | b = {':Git blame' , 'blame' } , 52 | B = {':GBrowse' , 'browse' } , 53 | c = {':Conflicted' , 'Conflicted' } , 54 | C = {':GitNextConflict' , 'Next Conflicted' } , 55 | d = {':Gvdiffsplit' , 'diff' } , 56 | D = {':Gdiffsplit' , 'diff split' } , 57 | g = {':GGrep' , 'git grep' } , 58 | s = {':Git' , 'status' } , 59 | m = {':GitMessenger' , 'show current line commit' } , 60 | h = 'highlight hunks' , 61 | H = 'preview hunk' , 62 | j = 'next hunk' , 63 | k = 'prev hunk' , 64 | u = 'undo hunk' , 65 | l = {':0Gclog' , 'git log current file' } , 66 | e = {':Gedit' , 'edit file from git log' } , 67 | L = {':Glog' , 'git log project' } , 68 | p = {':AsyncRun git push' , 'push' } , 69 | P = {':Git pull' , 'pull' } , 70 | r = {':GRemove' , 'remove' } , 71 | v = {':GV' , 'view commits' } , 72 | V = {':GV!' , 'view buffer commits' } , 73 | }, 74 | d = { 75 | name = '+diff' , 76 | ['1'] = 'Diff 2 version from register [1]' , 77 | h = 'Diff with head version' , 78 | p = 'Diff with previous version' , 79 | o = 'Conflict get our version' , 80 | t = 'Conflict get their verion' , 81 | b = 'Conflict diff both version' , 82 | B = 'Conflict diff both rev version' , 83 | }, 84 | [""] = { 85 | name = "nvim dev utility", 86 | l = "excute line", 87 | x = "excute file" 88 | }, 89 | t = { 90 | name = '+terminal' , 91 | [';'] = 'toggle terminal' , 92 | f = {':FloatermNew fzf' , 'fzf' } , 93 | g = {':FloatermNew lazygit' , 'git' } , 94 | d = {':FloatermNew lazydocker' , 'docker' } , 95 | n = {':FloatermNew node' , 'node' } , 96 | N = {':FloatermNew fm' , 'fm' } , 97 | t = {':FloatermToggle' , 'toggle' } , 98 | }, 99 | [';'] = { 100 | name = "+find" 101 | } 102 | },{prefix = ""}) 103 | 104 | 105 | vim.api.nvim_exec ([[ 106 | augroup which_key_buf 107 | autocmd! 108 | autocmd VimEnter * :lua require("wind.plug.which-key").on_enter() 109 | augroup end 110 | ]],false) 111 | 112 | return { 113 | on_enter = function () 114 | for key, value in pairs(vim.keymap.which_key) do 115 | wk.register(value,{prefix = key}) 116 | end 117 | end 118 | } 119 | -------------------------------------------------------------------------------- /plugin/key.vim: -------------------------------------------------------------------------------- 1 | " vim: foldmethod=marker sw=2 formatoptions-=o foldlevel=0 2 | " My vim my way :) 3 | " Keyboard config 4 | " ===================================== 5 | 6 | noremap :update 7 | vnoremap :update 8 | inoremap :update 9 | 10 | nnoremap u 11 | inoremap u 12 | 13 | 14 | " Shortcutting split navigation 15 | nnoremap h 16 | nnoremap j 17 | nnoremap k 18 | nnoremap l 19 | tnoremap h 20 | tnoremap j 21 | tnoremap k 22 | tnoremap l 23 | inoremap h 24 | inoremap j 25 | inoremap k 26 | inoremap l 27 | tnoremap 28 | 29 | nnoremap k v:count == 0 ? 'gk' : 'k' 30 | nnoremap j v:count == 0 ? 'gj' : 'j' 31 | xnoremap k v:count == 0 ? 'gk' : 'k' 32 | xnoremap j v:count == 0 ? 'gj' : 'j' 33 | " nnoremap 0 gg 34 | onoremap H ^ 35 | nnoremap H ^ 36 | vnoremap H ^ 37 | " nnoremap gg ^ 38 | nnoremap L $ 39 | onoremap L $ 40 | vnoremap L $ 41 | 42 | "navigation and edit in insert mode and command mode 43 | "it is similar to any terminal emulator or it from zsh?? 44 | "someone say it from emac but who care? 45 | inoremap pumvisible()? "":"$" 46 | inoremap 47 | inoremap 0d$a 48 | inoremap 49 | inoremap 50 | "seem like c-h is default of vim 51 | " make it trigger bs 52 | imap 53 | 54 | nnoremap ; : 55 | 56 | " fast select by press vvv dont need to press Shift V 57 | vmap v (expand_region_expand) 58 | vmap u (expand_region_shrink) 59 | 60 | 61 | " Disable Ex mode 62 | " use for run macro 63 | nnoremap Q @q 64 | vnoremap Q :norm @q 65 | nnoremap x "_x 66 | 67 | " switch between current and last buffer 68 | nnoremap g. 69 | " copy line to paste in visual mode with out new line 70 | nmap yl ^vg_y 71 | 72 | " paste in visual mode automatic put to register 1 73 | " if you want to use g0 it will retrieve cut text 74 | " register 0 it don't work over ssh 75 | xnoremap p wind#IsEndOfLine() ? '"1dp' :'"1dP' 76 | " xnoremap P "1dPgv 77 | 78 | " copy from register 1 79 | nmap g0 "1p 80 | 81 | " replace text object from register vscode have a function for this but it 82 | " https://github.com/vim-scripts/ReplaceWithRegister 83 | " need griw not grw 84 | 85 | " nmap grw viwp 86 | " stupid but it work because i want it can repeat 87 | nnoremap grw viw"1y:let @/=@1:let @2=@+cgn2:let @+=@2 88 | nmap grt vitp 89 | nmap grat viatp 90 | 91 | " goto bracket i don't want to use shift key % 92 | nmap g5 % 93 | 94 | nnoremap ggVG 95 | " use alt-a for increase number" 96 | nnoremap 97 | vnoremap 98 | 99 | " nnoremap gb :call GotoJump() 100 | 101 | 102 | nnoremap :Commentary 103 | 104 | nnoremap :Commentary 105 | " commentary code c-/ 106 | nnoremap :Commentary 107 | inoremap :Commentary 108 | vnoremap :Commentarygv 109 | 110 | " Move line when select,it can combine with count 111 | " Map to ctrl + shift + J,K on alacritty 112 | nnoremap j V:call wind#MoveLine(1) 113 | nnoremap k V:call wind#MoveLine(-1) 114 | 115 | vmap j :call wind#MoveLine(1) 116 | vmap k :call wind#MoveLine(-1) 117 | 118 | " duplicate line my old style from visual studio for duplicate line with 119 | " ctrl+shift+d 120 | nmap d :t. 121 | vmap d yP'> 122 | 123 | " map to ctrl tab it make me feel like i move tab on chrome" 124 | 125 | " it map to special characters on terminal use 126 | nnoremap 1 1gt 127 | nnoremap 2 2gt 128 | nnoremap 3 3gt 129 | nnoremap 4 4gt 130 | nnoremap 5 5gt 131 | nnoremap 6 6gt 132 | " tab move 133 | nnoremap 1gt 134 | nnoremap 2gt 135 | nnoremap 3gt 136 | nnoremap 4gt 137 | nnoremap 5gt 138 | nnoremap 6gt 139 | nnoremap 7gt 140 | 141 | nnoremap t :tabnext 142 | inoremap t :tabnext 143 | 144 | " scroll the viewport faster 145 | " sorry c-d 146 | nnoremap 7jzz 147 | nnoremap 7kzz 148 | 149 | " Correct typos in insert mode. 150 | inoremap u[s1z=`]au 151 | 152 | " keep visual selection when indenting/outdenting 153 | vmap > >gv 154 | vmap < gc :nohl 158 | nmap gl (MyLogger) 159 | nnoremap gq :call wind#SuperQuit() 160 | " ~~~~~ mytab openfile command 161 | nnoremap gf :TabCustomOpen =expand("") 162 | 163 | let g:tmux_navigator_no_mappings = 1 164 | let g:tmux_navigator_disable_when_zoomed = 1 165 | 166 | nmap s :HopChar2 167 | 168 | " Execute Vimscript {{{ 169 | " copy from @tj 170 | " Map execute this line 171 | function! s:executor() abort 172 | if &ft == 'lua' 173 | call execute(printf(":lua %s", getline("."))) 174 | elseif &ft == 'vim' 175 | exe getline(">") 176 | endif 177 | endfunction 178 | nnoremap x :call executor() 179 | 180 | vnoremap x :exe join(getline("'<","'>"),'') 181 | " Execute this file 182 | if get(g:,'save_and_exec',0)==0 183 | let g:save_and_exec=1 184 | function! s:save_and_exec() abort 185 | if &filetype == 'vim' 186 | :silent! write 187 | :source % 188 | elseif &filetype == 'lua' 189 | :silent! write 190 | :luafile % 191 | endif 192 | endfunction 193 | endif 194 | nnoremap x :call save_and_exec() 195 | " }}} 196 | 197 | 198 | -------------------------------------------------------------------------------- /lua/wind/plug/lsp/lsp.lua: -------------------------------------------------------------------------------- 1 | local lsp_util = require 'vim.lsp.util' 2 | local utils = import'core.utils' 3 | local map = utils.map 4 | local mapBuf = utils.mapBuf 5 | 6 | vim.fn.sign_define('LspDiagnosticsSignError', {text='', texthl='LspDiagnosticsSignError'}) 7 | vim.fn.sign_define('LspDiagnosticsSignWarning', {text='', texthl='LspDiagnosticsSignWarning'}) 8 | vim.fn.sign_define('LspDiagnosticsSignInformation', {text='', texthl='LspDiagnosticsSignInformation'}) 9 | vim.fn.sign_define('LspDiagnosticsSignHint', {text='', texthl='LspDiagnosticsSignHint'}) 10 | 11 | 12 | local apply_format =function(err, _, result, _, bufnr) 13 | if err ~= nil or result == nil then 14 | return 15 | end 16 | local view = vim.fn.winsaveview() 17 | local totaLine1 = vim.fn.line('$') 18 | local marks= vim.fn.getmarklist() 19 | vim.lsp.util.apply_text_edits(result, bufnr) 20 | vim.fn.winrestview(view) 21 | 22 | local totalLine2 = vim.fn.line('$') 23 | -- restore marks 24 | for _,m in pairs(marks) do 25 | if string.match(m.mark, "'[a-zA-Z]") then 26 | if bufnr == m.pos[1] then 27 | m.pos[2] = m.pos[2] + totalLine2 - totaLine1 28 | if m.pos[2] > 0 and m.pos[2] < totalLine2 then 29 | vim.fn.setpos(m.mark,m.pos) 30 | end 31 | end 32 | end 33 | end 34 | if bufnr == vim.api.nvim_get_current_buf() then 35 | vim.api.nvim_command("noautocmd :update") 36 | end 37 | end 38 | vim.lsp.handlers['textDocument/rangeFormatting'] = apply_format 39 | vim.lsp.handlers['textDocument/formatting'] = apply_format 40 | vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with( 41 | vim.lsp.diagnostic.on_publish_diagnostics, { 42 | -- Enable underline, use default values 43 | underline = true, 44 | -- Enable virtual text, override spacing to 5 45 | virtual_text = { 46 | spacing = 5, 47 | severity_limit = 'Warning', 48 | }, 49 | -- Disable a feature 50 | update_in_insert = false, 51 | } 52 | ) 53 | 54 | local statusline_lsp = function () 55 | local clients = vim.lsp.buf_get_clients(0) 56 | if #clients > 0 then 57 | local clientName = '' 58 | for _, server in pairs(clients) do 59 | if server then 60 | clientName = server.config.name .. "|" .. clientName 61 | end 62 | end 63 | vim.b.wind_lsp_server_name = string.format("%s", clientName:sub(0, string.len(clientName) -1)) 64 | return vim.b.wind_lsp_server_name 65 | end 66 | return '' 67 | end 68 | 69 | local mappping = function (bufnr) 70 | mapBuf(bufnr, 'n' , 'gh' , "lua require('lspsaga.hover').render_hover_doc()" ) 71 | mapBuf(bufnr, 'n' , 'gH' , "lua require('lspsaga.signaturehelp').signature_help()" ) 72 | mapBuf(bufnr, 'n' , '' , "lua require'lspsaga.provider'.lsp_finder()" ) 73 | mapBuf(bufnr, 'n' , 'gpd' , "lua vim.lsp.buf.peek_definition()" ) 74 | mapBuf(bufnr, 'n' , 'gtd' , "lua vim.lsp.buf.type_definition()" ) 75 | mapBuf(bufnr, 'v' , 'f' , "lua vim.lsp.buf.formatting()" ) 76 | mapBuf(bufnr, 'n' , '' , "lua require('lspsaga.rename').rename()" ) 77 | mapBuf(bufnr, 'n' , 'gse' , "lua vim.lsp.diagnostic.goto_next({severity_limit = 3 })" ) 78 | mapBuf(bufnr, 'n' , 'gsb' , "lua vim.lsp.diagnostic.goto_prev()" ) 79 | 80 | mapBuf(bufnr, 'v' , 'a' , "'<,'>lua require('lspsaga.codeaction').range_code_action()") 81 | mapBuf(bufnr, 'n' , 'a' , 'lua require("lspsaga.codeaction").code_action()' ) 82 | mapBuf(bufnr, 'n' , 'go' , 'lua Wind.load_plug("telescope").picker_document_symbol()') 83 | mapBuf(bufnr, 'n' , 'gd' , 'lua Wind.load_plug("telescope").goto_definition()') 84 | mapBuf(bufnr, 'n' , 'gD' , 'lua vim.lsp.buf.definition()') 85 | mapBuf(bufnr, 'n' , 'gsr' , 'Telescope lsp_references') 86 | mapBuf(bufnr, 'n' , 'ga' , 'Telescope lsp_code_actions') 87 | mapBuf(bufnr, 'n' , 'gsl' , "Lspsaga diagnostic_jump_next") 88 | end 89 | 90 | local extend_obj = {} 91 | 92 | local on_attach_vim = function(client , bufnr) 93 | local capabilities = vim.lsp.protocol.make_client_capabilities() 94 | capabilities.textDocument.completion.completionItem.snippetSupport = true 95 | -- require'completion'.on_attach(client) 96 | vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') 97 | statusline_lsp() 98 | mappping(bufnr) 99 | if extend_obj.on_attach_vim ~= nil then 100 | extend_obj.on_attach_vim(client,bufnr) 101 | end 102 | end 103 | 104 | local lsp_extend = function(obj) 105 | extend_obj= vim.tbl_extend('force', extend_obj, obj) 106 | end 107 | 108 | local lsp_setup = function(lsp) 109 | -- check nil if it already setup and reload 110 | if lsp ~= nil and lsp.setup ~= nil then 111 | lsp.setup({ 112 | on_attach = on_attach_vim 113 | }) 114 | end 115 | end 116 | 117 | local onSignatureHelp = function() 118 | if vim.b.wind_lsp_server_name and string.len(vim.b.wind_lsp_server_name) > 1 then 119 | local params = lsp_util.make_position_params() 120 | return vim.lsp.buf_request(1, 'textDocument/signatureHelp', params ,nil) 121 | end 122 | end 123 | 124 | local load_lsp = function (lang) 125 | local path = string.format('%s/lua/wind/plug/lsp/lang/%s.lua', Wind.vim_path, lang) 126 | if vim.fn.filereadable(path) == 1 then 127 | return import('plug.lsp.lang.'..lang) 128 | else 129 | local nvim_lsp = require('lspconfig') 130 | if nvim_lsp[lang] ~= nil then 131 | lsp_setup(nvim_lsp[lang]) 132 | else 133 | print("Not found Lsp:" .. lang) 134 | end 135 | end 136 | end 137 | 138 | return { 139 | load_lsp = load_lsp, 140 | on_attach_vim = on_attach_vim, 141 | lsp_setup = lsp_setup, 142 | lsp_extend = lsp_extend, 143 | onSignatureHelp = onSignatureHelp , 144 | statusline_lsp = statusline_lsp , 145 | } 146 | -------------------------------------------------------------------------------- /lua/wind/general/setting.lua: -------------------------------------------------------------------------------- 1 | 2 | local function bind_option(options) 3 | for k, v in pairs(options) do 4 | if v == true or v == false then 5 | vim.cmd('set ' .. k) 6 | else 7 | vim.cmd('set ' .. k .. '=' .. v) 8 | end 9 | end 10 | end 11 | 12 | local function load_options() 13 | local options = { 14 | termguicolors = true; 15 | mouse = "nv"; 16 | errorbells = true; 17 | visualbell = true; 18 | hidden = true; 19 | fileformats = "unix,mac,dos"; 20 | magic = true; 21 | virtualedit = "block"; 22 | encoding = "utf-8"; 23 | viewoptions = "folds,cursor,curdir,slash,unix"; 24 | sessionoptions = "curdir,help,tabpages,winsize"; 25 | clipboard = "unnamedplus"; 26 | wildignorecase = true; 27 | wildignore = ".git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**,**/bower_modules/**"; 28 | backup = false; 29 | writebackup = false; 30 | undofile = true; 31 | swapfile = false; 32 | directory = Wind.cache_dir .. "swag/"; 33 | undodir = Wind.cache_dir .. "undo/"; 34 | backupdir = Wind.cache_dir .. "backup/"; 35 | viewdir = Wind.cache_dir .. "view/"; 36 | spellfile = Wind.cache_dir .. "spell/en.uft-8.add"; 37 | history = 2000; 38 | shada = "!,'300,<50,@100,s10,h"; 39 | backupskip = "/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*,/private/var/*,.vault.vim"; 40 | smarttab = true; 41 | shiftround = true; 42 | timeout = true; 43 | ttimeout = true; 44 | timeoutlen = 500; 45 | ttimeoutlen = 10; 46 | updatetime = 100; 47 | redrawtime = 1500; 48 | ignorecase = true; 49 | smartcase = true; 50 | infercase = true; 51 | incsearch = true; 52 | -- wrapscan = true; 53 | complete = ".,w,b,k"; 54 | inccommand = "nosplit"; 55 | grepformat = "%f:%l:%c:%m"; 56 | grepprg = 'rg --hidden --vimgrep --smart-case --'; 57 | breakat = [[\ \ ;:,!?]]; 58 | startofline = true; 59 | -- whichwrap = "h,l,<,>,[,],~"; 60 | splitbelow = true; 61 | splitright = true; 62 | switchbuf = "useopen"; 63 | backspace = "indent,eol,start"; 64 | diffopt = "filler,iwhite,internal,algorithm:patience"; 65 | completeopt = "menu,menuone,noselect"; 66 | jumpoptions = "stack"; 67 | showmode = false; 68 | shortmess = "aoOTIcF"; 69 | scrolloff = 3; 70 | sidescrolloff = 5; 71 | foldlevelstart = 99; 72 | ruler = false; 73 | list = true; 74 | showtabline = 2; 75 | pumheight = 15; 76 | helpheight = 12; 77 | previewheight = 12; 78 | showcmd = false; 79 | cmdheight = 2; 80 | cmdwinheight = 5; 81 | equalalways = false; 82 | laststatus = 2; 83 | display = "lastline"; 84 | showbreak = "↳ "; 85 | listchars = "tab:………,nbsp:░,extends:»,precedes:«,trail:·"; 86 | pumblend = 10; 87 | winblend = 10; 88 | confirm = true; 89 | cursorline = true; 90 | } 91 | 92 | local bw_local = { 93 | nowrap = true, 94 | synmaxcol = 2500; 95 | formatoptions = "1jcroql"; 96 | textwidth = 80; 97 | expandtab = true; 98 | autoindent = true; 99 | tabstop = 2; 100 | shiftwidth = 2; 101 | softtabstop = -1; 102 | breakindentopt = "shift:2,min:20"; 103 | linebreak = true; 104 | number = true; 105 | relativenumber = true; 106 | foldenable = true; 107 | signcolumn = "yes"; 108 | conceallevel = 2; 109 | } 110 | 111 | if Wind.is_mac then 112 | vim.g.clipboard = { 113 | name = "macOS-clipboard", 114 | copy = { 115 | ["+"] = "pbcopy", 116 | ["*"] = "pbcopy", 117 | }, 118 | paste = { 119 | ["+"] = "pbpaste", 120 | ["*"] = "pbpaste", 121 | }, 122 | cache_enabled = 0 123 | } 124 | vim.g.python_host_prog = '/usr/bin/python' 125 | vim.g.python3_host_prog = '/usr/local/bin/python3' 126 | end 127 | for name, value in pairs(options) do 128 | vim.o[name] = value 129 | end 130 | bind_option(bw_local) 131 | end 132 | 133 | local function disable_distribution_plugins() 134 | vim.g.did_install_default_menus = 1 135 | vim.g.loaded_gzip = 1 136 | vim.g.loaded_tar = 1 137 | vim.g.loaded_tarPlugin = 1 138 | vim.g.loaded_zip = 1 139 | vim.g.loaded_zipPlugin = 1 140 | vim.g.loaded_getscript = 1 141 | vim.g.loaded_getscriptPlugin = 1 142 | vim.g.loaded_vimball = 1 143 | vim.g.loaded_vimballPlugin = 1 144 | vim.g.loaded_matchit = 1 145 | vim.g.loaded_matchparen = 1 146 | vim.g.loaded_2html_plugin = 1 147 | vim.g.loaded_logiPat = 1 148 | vim.g.loaded_rrhelper = 1 149 | vim.g.loaded_netrw = 1 150 | vim.g.loaded_netrwPlugin = 1 151 | vim.g.loaded_netrwSettings = 1 152 | vim.g.loaded_netrwFileHandlers = 1 153 | end 154 | 155 | local function load_theme(theme_name) 156 | local themepath = string.format('%s/lua/wind/general/themes/%s.lua', Wind.vim_path, theme_name) 157 | if vim.fn.filereadable(themepath) == 1 then 158 | import(themepath) 159 | else 160 | vim.cmd(string.format([[colorscheme %s]], vim.g.wind_theme)) 161 | end 162 | end 163 | 164 | local function load_command() 165 | vim.api.nvim_exec([[ 166 | filetype plugin indent on 167 | syntax on 168 | command! -nargs=* TabCustomOpen call v:lua.import('core.nav').wind_open() 169 | command! -nargs=* WindDev lua Wind.is_dev=true 170 | " enable italic in tmux 171 | set t_ZH=^[[3m 172 | set t_ZR=^[[23m 173 | ]],true) 174 | end 175 | 176 | local function setup() 177 | disable_distribution_plugins() 178 | load_options() 179 | load_theme(vim.g.wind_theme) 180 | load_command() 181 | end 182 | 183 | setup() 184 | 185 | return { 186 | load_theme = load_theme 187 | } 188 | -------------------------------------------------------------------------------- /lua/wind/core/plug.lua: -------------------------------------------------------------------------------- 1 | local paq = require('paq-nvim').paq 2 | 3 | -- default config it will load after packadd 4 | local configs = {} 5 | 6 | 7 | -- manual pack it load use load_pack 8 | local manual_packs = {} 9 | -- list back 10 | local packs = {} 11 | 12 | local M = {} 13 | 14 | -- customize paq 15 | M.Plug = function(opts) 16 | local plugin_name = '' 17 | if type(opts) == 'string' then 18 | plugin_name = string.match(opts, '/(.*)') 19 | opts = { opts } 20 | else 21 | plugin_name = string.match(opts[1], '/(.*)') 22 | end 23 | local add_to_rtp = true 24 | if opts.manual == true then 25 | -- that option mean you need to load plugin by function load_pack 26 | opts.name = plugin_name 27 | table.insert(manual_packs, vim.deepcopy(opts)) 28 | opts.opt = true 29 | opts.async = false 30 | opts.manual = false 31 | opts.config = false 32 | opts.on = false 33 | add_to_rtp = false 34 | end 35 | 36 | if opts.on then 37 | M.load_on_command(plugin_name, opts.on, opts.confg, opts.before) 38 | opts.before = false 39 | opts.config = false 40 | add_to_rtp = false 41 | end 42 | 43 | if opts.event then 44 | M.load_on_event(plugin_name, opts.event, opts.config, opts.before) 45 | opts.before = false 46 | opts.config = false 47 | add_to_rtp = false 48 | end 49 | 50 | if opts.key then 51 | M.load_on_key(plugin_name, opts.key, opts.config, opts.before) 52 | opts.before = false 53 | opts.config = false 54 | add_to_rtp = false 55 | end 56 | 57 | if opts.ft then 58 | M.load_on_ft(plugin_name, opts.ft, opts.config, opts.before) 59 | opts.before = false 60 | opts.config = false 61 | add_to_rtp = false 62 | end 63 | 64 | if opts.cond == false then 65 | opts.config = false 66 | add_to_rtp = false 67 | end 68 | 69 | -- force all plugin is option except the opt = false 70 | -- paq will add this to folder start but i don't like it because 71 | -- if i remove the plugin from config file it still loading that 72 | if opts.opt == nil then 73 | opts.opt = true 74 | end 75 | 76 | if add_to_rtp == true then 77 | table.insert(packs, plugin_name) 78 | end 79 | 80 | -- loading config 81 | if opts.config then 82 | table.insert(configs, opts.config) 83 | end 84 | 85 | -- print(plugin_name) 86 | paq(opts) 87 | end 88 | 89 | M.load_config = function() 90 | for _, plugin in pairs(packs) do 91 | local ok, msg = pcall(vim.cmd, 'packadd ' .. plugin) 92 | if not ok then 93 | print('load pack error: ' .. plugin) 94 | print(msg) 95 | end 96 | end 97 | 98 | for _, value in pairs(configs) do 99 | Wind.load_plug(value) 100 | end 101 | end 102 | 103 | M.load_on_event = function(plugin_name, event, cfg, before) 104 | cfg = cfg or '' 105 | before = before or'' 106 | vim.api.nvim_exec( 107 | string.format( 108 | [[au %s * ++once call v:lua.Wind.plug_cb_event('%s','%s','%s')]], 109 | event, 110 | plugin_name, 111 | cfg, 112 | before 113 | ), 114 | false 115 | ) 116 | end 117 | 118 | M.plug_cb_event = function(plugin_name, cfg, before) 119 | if #before > 1 then 120 | Wind.load_plug(before) 121 | end 122 | local ok, msg = pcall(vim.cmd, 'packadd ' .. plugin_name) 123 | if not ok then 124 | print('load pack error: ' .. plugin_name) 125 | print(msg) 126 | end 127 | if #cfg > 1 then 128 | Wind.load_plug(cfg) 129 | end 130 | end 131 | 132 | M.load_on_key = function (plugin_name, key, cfg, before) 133 | if type(key) == 'table' then 134 | for _, k in pairs(key) do 135 | M.load_on_key(plugin_name, k, cfg, before) 136 | end 137 | return 138 | end 139 | vim.api.nvim_set_keymap('n', key, 140 | string.format("lua Wind.plug_cb_key('%s','%s','%s','%s')", 141 | key, 142 | plugin_name, 143 | cfg or '', 144 | before or '' 145 | ), 146 | {noremap = true} 147 | ) 148 | end 149 | 150 | 151 | M.plug_cb_key = function (key, plugin_name, cfg, before) 152 | vim.api.nvim_del_keymap('n', key) 153 | M.plug_cb_event(plugin_name, cfg, before) 154 | vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, false, true), 'x', true) 155 | end 156 | 157 | M.load_on_ft = function (plugin_name, ft, cfg, before) 158 | if type(ft)=='table' then 159 | ft = table.concat(ft, ',') 160 | end 161 | vim.cmd(string.format( 162 | [[au FileType %s ++once call v:lua.Wind.plug_cb_event('%s','%s','%s')]], 163 | ft, 164 | plugin_name, 165 | cfg or '', 166 | before or '' 167 | )) 168 | end 169 | 170 | M.load_on_command = function(plugin_name, on_cmd, cfg, before) 171 | if type(on_cmd) == 'string' then 172 | on_cmd = { on_cmd } 173 | end 174 | for _, command in pairs(on_cmd) do 175 | vim.cmd(string.format( 176 | [[command! -nargs=* -range -bang -complete=file %s call v:lua.Wind.plug_cb_cmd('%s','%s','%s','%s',)]], 177 | command, 178 | command, 179 | plugin_name, 180 | cfg or ' ', 181 | before or '' 182 | )) 183 | end 184 | end 185 | 186 | M.plug_cb_cmd = function(cmd, plugin_name, cfg, before, ...) 187 | vim.cmd(string.format([[delcommand %s]], cmd)) 188 | M.plug_cb_event(plugin_name, cfg, before) 189 | local params = { ... } 190 | vim.cmd(cmd .. ' ' .. table.concat(params, ' ')) 191 | end 192 | 193 | M.load_pack = function(name) 194 | for _, v in pairs(manual_packs) do 195 | if v.name == name then 196 | local ok, msg = pcall(vim.cmd, 'packadd ' .. name) 197 | if not ok then 198 | print('load pack error: ' .. name) 199 | print(msg) 200 | end 201 | if v.config then 202 | Wind.load_plug(v.config) 203 | end 204 | manual_packs.name = '' 205 | return 206 | end 207 | end 208 | print("We can't not find that pack " .. name) 209 | end 210 | 211 | --sorry paq it is a dirty think but i keep typing 212 | --Plug in my command and my mind 213 | vim.api.nvim_exec([[ 214 | command! PlugInstall lua require('paq-nvim').install() 215 | command! PlugUpdate lua require('paq-nvim').update() 216 | command! PlugClean lua require('paq-nvim').clean() 217 | command! PlugLogOpen lua require('paq-nvim').log_open() 218 | command! PlugLogClean lua require('paq-nvim').log_clean() 219 | ]], 220 | false 221 | ) 222 | 223 | Wind.load_pack = M.load_pack 224 | Wind.plug_cb_cmd = M.plug_cb_cmd 225 | Wind.plug_cb_event = M.plug_cb_event 226 | Wind.plug_cb_key = M.plug_cb_key 227 | return M 228 | -------------------------------------------------------------------------------- /snippets/typescript.json: -------------------------------------------------------------------------------- 1 | { 2 | "rinput":{ 3 | "prefix":"rinput", 4 | "body":"import { RImageUpload, RTabs } from '$components/ui/form/index';", 5 | "description":"" 6 | }, 7 | "rmodel":{ 8 | "prefix":"rmodel", 9 | "body":"import type { RModel } from '$common/model/rmodel';", 10 | "description":"" 11 | }, 12 | "eslint_disable":{ 13 | "prefix":"eslint_disable", 14 | "body":"// eslint-disable-next-line", 15 | "description":"" 16 | }, 17 | "oarrow":{ 18 | "prefix": "oai", 19 | "body": ["(o) => $0"], 20 | "description": "object arrow function" 21 | }, 22 | "farrow":{ 23 | "prefix": "oab", 24 | "body": ["(o) => {","\treturn $0"," }"], 25 | "description": "Constructor" 26 | }, 27 | "jsdoc": { 28 | "prefix": "jsdoc", 29 | "body": ["/**", " *$0", " */"], 30 | "description": "Constructor" 31 | }, 32 | "Constructor": { 33 | "prefix": "ctor", 34 | "body": ["/**", " *", " */", "constructor() {", "\tsuper();", "\t$0", "}"], 35 | "description": "Constructor" 36 | }, 37 | "Class Definition": { 38 | "prefix": "class", 39 | "body": [ 40 | "class ${1:name} {", 41 | "\tconstructor(${2:parameters}) {", 42 | "\t\t$0", 43 | "\t}", 44 | "}" 45 | ], 46 | "description": "Class Definition" 47 | }, 48 | "Public Method Definition": { 49 | "prefix": "public method", 50 | "body": ["/**", " * ${1:name}", " */", "public ${1:name}() {", "\t$0", "}"], 51 | "description": "Public Method Definition" 52 | }, 53 | "Private Method Definition": { 54 | "prefix": "private method", 55 | "body": ["private ${1:name}() {", "\t$0", "}"], 56 | "description": "Private Method Definition" 57 | }, 58 | "Import external module.": { 59 | "prefix": "import statement", 60 | "body": ["import { $0 } from \"${1:module}\";"], 61 | "description": "Import external module." 62 | }, 63 | "Property getter": { 64 | "prefix": "get", 65 | "body": [ 66 | "", 67 | "public get ${1:value}() : ${2:string} {", 68 | "\t${3:return $0}", 69 | "}", 70 | "" 71 | ], 72 | "description": "Property getter" 73 | }, 74 | "Log to the console": { 75 | "prefix": "log", 76 | "body": ["console.log($1);", "$0"], 77 | "description": "Log to the console" 78 | }, 79 | "Log warning to console": { 80 | "prefix": "warn", 81 | "body": ["console.warn($1);", "$0"], 82 | "description": "Log warning to the console" 83 | }, 84 | "Log error to console": { 85 | "prefix": "error", 86 | "body": ["console.error($1);", "$0"], 87 | "description": "Log error to the console" 88 | }, 89 | "Define a full property": { 90 | "prefix": "prop", 91 | "body": [ 92 | "", 93 | "private _${1:value} : ${2:string};", 94 | "public get ${1:value}() : ${2:string} {", 95 | "\treturn this._${1:value};", 96 | "}", 97 | "public set ${1:value}(v : ${2:string}) {", 98 | "\tthis._${1:value} = v;", 99 | "}", 100 | "" 101 | ], 102 | "description": "Define a full property" 103 | }, 104 | "Triple-slash reference": { 105 | "prefix": "ref", 106 | "body": ["/// ", "$0"], 107 | "description": "Triple-slash reference" 108 | }, 109 | "Property setter": { 110 | "prefix": "set", 111 | "body": [ 112 | "", 113 | "public set ${1:value}(v : ${2:string}) {", 114 | "\tthis.$3 = v;", 115 | "}", 116 | "" 117 | ], 118 | "description": "Property setter" 119 | }, 120 | "Throw Exception": { 121 | "prefix": "throw", 122 | "body": ["throw new Error(\"$1\");", "$0"], 123 | "description": "Throw Exception" 124 | }, 125 | "For Loop": { 126 | "prefix": "for", 127 | "body": [ 128 | "for (let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++) {", 129 | "\tconst ${3:element} = ${2:array}[${1:index}];", 130 | "\t$0", 131 | "}" 132 | ], 133 | "description": "For Loop" 134 | }, 135 | "For-Each Loop using =>": { 136 | "prefix": "foreach", 137 | "body": ["forEach(o => {", "\t$1", "});"], 138 | "description": "For-Each Loop using =>" 139 | }, 140 | "For-In Loop": { 141 | "prefix": "forin", 142 | "body": [ 143 | "for (const ${1:key} in ${2:object}) {", 144 | "\tif (Object.prototype.hasOwnProperty.call(${2:object}, ${1:key})) {", 145 | "\t\tconst ${3:element} = ${2:object}[${1:key}];", 146 | "\t\t$0", 147 | "\t}", 148 | "}" 149 | ], 150 | "description": "For-In Loop" 151 | }, 152 | "For-Of Loop": { 153 | "prefix": "forof", 154 | "body": ["for (const ${1:iterator} of ${2:object}) {", "\t$0", "}"], 155 | "description": "For-Of Loop" 156 | }, 157 | "For-Await-Of Loop": { 158 | "prefix": "forawaitof", 159 | "body": ["for await (const ${1:iterator} of ${2:object}) {", "\t$0", "}"], 160 | "description": "For-Await-Of Loop" 161 | }, 162 | "Function Statement": { 163 | "prefix": "function", 164 | "body": ["function ${1:name}(${2:params}:${3:type}) {", "\t$0", "}"], 165 | "description": "Function Statement" 166 | }, 167 | "If Statement": { 168 | "prefix": "if", 169 | "body": ["if (${1:condition}) {", "\t$0", "}"], 170 | "description": "If Statement" 171 | }, 172 | "If-Else Statement": { 173 | "prefix": "ifelse", 174 | "body": ["if (${1:condition}) {", "\t$0", "} else {", "\t", "}"], 175 | "description": "If-Else Statement" 176 | }, 177 | "New Statement": { 178 | "prefix": "new", 179 | "body": ["const ${1:name} = new ${2:type}(${3:arguments});$0"], 180 | "description": "New Statement" 181 | }, 182 | "Switch Statement": { 183 | "prefix": "switch", 184 | "body": [ 185 | "switch (${1:key}) {", 186 | "\tcase ${2:value}:", 187 | "\t\t$0", 188 | "\t\tbreak;", 189 | "", 190 | "\tdefault:", 191 | "\t\tbreak;", 192 | "}" 193 | ], 194 | "description": "Switch Statement" 195 | }, 196 | "While Statement": { 197 | "prefix": "while", 198 | "body": ["while (${1:condition}) {", "\t$0", "}"], 199 | "description": "While Statement" 200 | }, 201 | "Do-While Statement": { 202 | "prefix": "dowhile", 203 | "body": ["do {", "\t$0", "} while (${1:condition});"], 204 | "description": "Do-While Statement" 205 | }, 206 | "Try-Catch Statement": { 207 | "prefix": "trycatch", 208 | "body": ["try {", "\t$0", "} catch (${1:error}) {", "\t", "}"], 209 | "description": "Try-Catch Statement" 210 | }, 211 | "Set Timeout Function": { 212 | "prefix": "settimeout", 213 | "body": ["setTimeout(() => {", "\t$0", "}, ${1:timeout});"], 214 | "description": "Set Timeout Function" 215 | }, 216 | "Region Start": { 217 | "prefix": "#region", 218 | "body": ["//#region $0"], 219 | "description": "Folding Region Start" 220 | }, 221 | "Region End": { 222 | "prefix": "#endregion", 223 | "body": ["//#endregion"], 224 | "description": "Folding Region End" 225 | }, 226 | "new Promise": { 227 | "prefix": "newpromise", 228 | "body": ["new Promise<$1:type>((resolve, reject) => {", "\t$1", "})"], 229 | "description": "Create a new Promise" 230 | }, 231 | "Async Function Statement": { 232 | "prefix": "async function", 233 | "body": ["async function ${1:name}(${2:params}:${3:type}) {", "\t$0", "}"], 234 | "description": "Async Function Statement" 235 | }, 236 | "Async Function Expression": { 237 | "prefix": "async arrow function", 238 | "body": ["async (${1:params}:${2:type}) => {", "\t$0", "}"], 239 | "description": "Async Function Expression" 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /lua/wind/core/keymap.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/tjdevries/astronauta.nvim/blob/master/lua/astronauta/keymap.lua 2 | -- copy from @tjdevries and modify to fix my style 3 | -- and I want it can add description to display on which_key 4 | -- 5 | local keymap={} 6 | 7 | -- Have to use a global to handle re-requiring this file and losing all of the keymap. 8 | -- In the future, the C code will handle this. 9 | __AstronautaMapStore = __AstronautaMapStore or {} 10 | keymap._store = __AstronautaMapStore 11 | keymap.which_key = {} 12 | 13 | keymap._create = function(f) 14 | table.insert(keymap._store, f) 15 | return #keymap._store 16 | end 17 | 18 | keymap._execute = function(id) 19 | return keymap._store[id]() 20 | end 21 | 22 | local parse_wk_desc = function (desc, lhs) 23 | if desc then 24 | local first_key,second_key,third_key 25 | if string.match(lhs, '') then 26 | first_key = "" 27 | second_key = lhs:sub(9, 9) 28 | third_key = lhs:sub(10, 10) 29 | else 30 | first_key = lhs:sub(1, 1) 31 | second_key = lhs:sub(2, 2) 32 | third_key = lhs:sub(3, 3) 33 | end 34 | 35 | if keymap.which_key[first_key] == nil and #first_key > 0 then 36 | keymap.which_key[first_key] = {} 37 | end 38 | local current = keymap.which_key[first_key] 39 | if third_key ~= nil and #third_key > 0 then 40 | if current[second_key] == nil then 41 | current[second_key] = {} 42 | end 43 | current[second_key][third_key] =desc 44 | else 45 | current[second_key]= desc 46 | end 47 | end 48 | end 49 | 50 | local make_mapper = function(mode, defaults, opts) 51 | if Wind.is_dev then 52 | opts.silent = false 53 | end 54 | local args, map_args = {}, {} 55 | for k, v in pairs(opts) do 56 | if type(k) == 'number' then 57 | args[k] = v 58 | else 59 | map_args[k] = v 60 | end 61 | end 62 | 63 | local lhs = opts.lhs or args[1] 64 | local rhs = opts.rhs or args[2] 65 | local desc = map_args.desc or args[3] 66 | local map_opts = vim.tbl_extend("force", defaults, map_args) 67 | map_opts.desc = nil 68 | 69 | parse_wk_desc(desc,lhs) 70 | 71 | local mapping 72 | if type(rhs) == 'string' then 73 | mapping = rhs 74 | 75 | elseif type(rhs) == 'function' then 76 | local func_id = keymap._create(rhs) 77 | 78 | mapping = string.format( 79 | [[v:lua.vim.keymap._execute(%s)]], func_id 80 | ) 81 | else 82 | error("Unexpected type for rhs:" .. tostring(rhs)) 83 | end 84 | 85 | if not map_opts.buffer then 86 | vim.api.nvim_set_keymap(mode, lhs, mapping, map_opts) 87 | else 88 | -- Clear the buffer after saving it 89 | local buffer = map_opts.buffer 90 | if buffer == true then 91 | buffer = 0 92 | end 93 | 94 | map_opts.buffer = nil 95 | 96 | vim.api.nvim_buf_set_keymap(buffer, mode, lhs, mapping, map_opts) 97 | end 98 | end 99 | 100 | --- Helper function for ':map'. 101 | --- 102 | --@see |vim.keymap.nmap| 103 | --- 104 | function keymap.map(opts) 105 | return make_mapper('', { noremap = false }, opts) 106 | end 107 | 108 | --- Helper function for ':noremap' 109 | --@see |vim.keymap.nmap| 110 | --- 111 | function keymap.noremap(opts) 112 | return make_mapper('', { noremap = true }, opts) 113 | end 114 | 115 | --- Helper function for ':nmap'. 116 | --- 117 | ---
    118 | ---   vim.keymap.nmap { 'lhs', function() print("real lua function") end, silent = true }
    119 | --- 
    120 | --@param opts (table): A table with keys: 121 | --- - [1] = left hand side: Must be a string 122 | --- - [2] = right hand side: Can be a string OR a lua function to execute 123 | --- - Other keys can be arguments to |:map|, such as "silent". See |nvim_set_keymap()| 124 | --- 125 | function keymap.nmap(opts) 126 | return make_mapper('n', { noremap = false }, opts) 127 | end 128 | 129 | --- Helper function for ':nnoremap' 130 | ---
    131 | ---   vim.keymap.nmap { 'lhs', function() print("real lua function") end, silent = true }
    132 | --- 
    133 | --@param opts (table): A table with keys 134 | --- - [1] = left hand side: Must be a string 135 | --- - [2] = right hand side: Can be a string OR a lua function to execute 136 | --- - Other keys can be arguments to |:map|, such as "silent". See |nvim_set_keymap()| 137 | --- 138 | --- 139 | function keymap.nnoremap(opts) 140 | return make_mapper('n', { noremap = true, silent = true}, opts) 141 | end 142 | 143 | --- Helper function for ':vmap'. 144 | --- 145 | --@see |vim.keymap.nmap| 146 | --- 147 | function keymap.vmap(opts) 148 | return make_mapper('v', { noremap = false, silent = true }, opts) 149 | end 150 | 151 | --- Helper function for ':vnoremap' 152 | --@see |vim.keymap.nmap| 153 | --- 154 | function keymap.vnoremap(opts) 155 | return make_mapper('v', { noremap = true, silent = true }, opts) 156 | end 157 | 158 | --- Helper function for ':xmap'. 159 | --- 160 | --@see |vim.keymap.nmap| 161 | --- 162 | function keymap.xmap(opts) 163 | return make_mapper('x', { noremap = false, silent = true }, opts) 164 | end 165 | 166 | --- Helper function for ':xnoremap' 167 | --@see |vim.keymap.nmap| 168 | --- 169 | function keymap.xnoremap(opts) 170 | return make_mapper('x', { noremap = true, silent = true }, opts) 171 | end 172 | 173 | --- Helper function for ':smap'. 174 | --- 175 | --@see |vim.keymap.nmap| 176 | --- 177 | function keymap.smap(opts) 178 | return make_mapper('s', { noremap = false, silent = true }, opts) 179 | end 180 | 181 | --- Helper function for ':snoremap' 182 | --@see |vim.keymap.nmap| 183 | --- 184 | function keymap.snoremap(opts) 185 | return make_mapper('s', { noremap = true, silent = true }, opts) 186 | end 187 | 188 | --- Helper function for ':omap'. 189 | --- 190 | --@see |vim.keymap.nmap| 191 | --- 192 | function keymap.omap(opts) 193 | return make_mapper('o', { noremap = false, silent = true }, opts) 194 | end 195 | 196 | --- Helper function for ':onoremap' 197 | --@see |vim.keymap.nmap| 198 | --- 199 | function keymap.onoremap(opts) 200 | return make_mapper('o', { noremap = true, silent = true }, opts) 201 | end 202 | 203 | --- Helper function for ':imap'. 204 | --- 205 | --@see |vim.keymap.nmap| 206 | --- 207 | function keymap.imap(opts) 208 | return make_mapper('i', { noremap = false , silent = true}, opts) 209 | end 210 | 211 | --- Helper function for ':inoremap' 212 | --@see |vim.keymap.nmap| 213 | --- 214 | function keymap.inoremap(opts) 215 | return make_mapper('i', { noremap = true, silent = true }, opts) 216 | end 217 | 218 | --- Helper function for ':lmap'. 219 | --- 220 | --@see |vim.keymap.nmap| 221 | --- 222 | function keymap.lmap(opts) 223 | return make_mapper('l', { noremap = false , silent = true}, opts) 224 | end 225 | 226 | --- Helper function for ':lnoremap' 227 | --@see |vim.keymap.nmap| 228 | --- 229 | function keymap.lnoremap(opts) 230 | return make_mapper('l', { noremap = true, silent = true }, opts) 231 | end 232 | 233 | --- Helper function for ':cmap'. 234 | --- 235 | --@see |vim.keymap.nmap| 236 | --- 237 | function keymap.cmap(opts) 238 | return make_mapper('c', { noremap = false , silent = true}, opts) 239 | end 240 | 241 | --- Helper function for ':cnoremap' 242 | --@see |vim.keymap.nmap| 243 | --- 244 | function keymap.cnoremap(opts) 245 | return make_mapper('c', { noremap = true, silent = true }, opts) 246 | end 247 | 248 | --- Helper function for ':tmap'. 249 | --- 250 | --@see |vim.keymap.nmap| 251 | --- 252 | function keymap.tmap(opts) 253 | return make_mapper('t', { noremap = false , silent = true}, opts) 254 | end 255 | 256 | --- Helper function for ':tnoremap' 257 | --@see |vim.keymap.nmap| 258 | --- 259 | function keymap.tnoremap(opts) 260 | return make_mapper('t', { noremap = true, silent = true }, opts) 261 | end 262 | 263 | 264 | --- Helper function for ':tnoremap' 265 | --@see |vim.keymap.nmap| 266 | --- 267 | function keymap.t(cmd) 268 | return vim.api.nvim_replace_termcodes(cmd, true, false, true) 269 | end 270 | 271 | vim.keymap = vim.keymap or keymap 272 | 273 | return keymap 274 | -------------------------------------------------------------------------------- /snippets/go.json: -------------------------------------------------------------------------------- 1 | { 2 | "single import": { 3 | "prefix": "im", 4 | "body": "import \"${1:package}\"", 5 | "description": "Snippet for import statement" 6 | }, 7 | "multiple imports": { 8 | "prefix": "ims", 9 | "body": "import (\n\t\"${1:package}\"\n)", 10 | "description": "Snippet for a import block" 11 | }, 12 | "single constant": { 13 | "prefix": "co", 14 | "body": "const ${1:name} = ${2:value}", 15 | "description": "Snippet for a constant" 16 | }, 17 | "multiple constants": { 18 | "prefix": "cos", 19 | "body": "const (\n\t${1:name} = ${2:value}\n)", 20 | "description": "Snippet for a constant block" 21 | }, 22 | "type interface declaration": { 23 | "prefix": "tyi", 24 | "body": "type ${1:name} interface {\n\t$0\n}", 25 | "description": "Snippet for a type interface" 26 | }, 27 | "type struct declaration": { 28 | "prefix": "tys", 29 | "body": "type ${1:name} struct {\n\t$0\n}", 30 | "description": "Snippet for a struct declaration" 31 | }, 32 | "package main and main function": { 33 | "prefix": "pkgm", 34 | "body": "package main\n\nfunc main() {\n\t$0\n}", 35 | "description": "Snippet for main package & function" 36 | }, 37 | "function declaration": { 38 | "prefix": "func", 39 | "body": "func $1($2) $3 {\n\t$0\n}", 40 | "description": "Snippet for function declaration" 41 | }, 42 | "variable declaration": { 43 | "prefix": "var", 44 | "body": "var ${1:name} ${2:type}", 45 | "description": "Snippet for a variable" 46 | }, 47 | "switch statement": { 48 | "prefix": "switch", 49 | "body": "switch ${1:expression} {\ncase ${2:condition}:\n\t$0\n}", 50 | "description": "Snippet for switch statement" 51 | }, 52 | "select statement": { 53 | "prefix": "sel", 54 | "body": "select {\ncase ${1:condition}:\n\t$0\n}", 55 | "description": "Snippet for select statement" 56 | }, 57 | "case clause": { 58 | "prefix": "cs", 59 | "body": "case ${1:condition}:$0", 60 | "description": "Snippet for case clause" 61 | }, 62 | "for statement": { 63 | "prefix": "for", 64 | "body": "for ${1:i} := 0; $1 < ${2:count}; $1${3:++} {\n\t$0\n}", 65 | "description": "Snippet for a for loop" 66 | }, 67 | "for range statement": { 68 | "prefix": "forr", 69 | "body": "for ${1:_, }${2:var} := range ${3:var} {\n\t$0\n}", 70 | "description": "Snippet for a for range loop" 71 | }, 72 | "channel declaration": { 73 | "prefix": "ch", 74 | "body": "chan ${1:type}", 75 | "description": "Snippet for a channel" 76 | }, 77 | "map declaration": { 78 | "prefix": "map", 79 | "body": "map[${1:type}]${2:type}", 80 | "description": "Snippet for a map" 81 | }, 82 | "empty interface": { 83 | "prefix": "in", 84 | "body": "interface{}", 85 | "description": "Snippet for empty interface" 86 | }, 87 | "if statement": { 88 | "prefix": "if", 89 | "body": "if ${1:condition} {\n\t$0\n}", 90 | "description": "Snippet for if statement" 91 | }, 92 | "else branch": { 93 | "prefix": "el", 94 | "body": "else {\n\t$0\n}", 95 | "description": "Snippet for else branch" 96 | }, 97 | "if else statement": { 98 | "prefix": "ie", 99 | "body": "if ${1:condition} {\n\t$2\n} else {\n\t$0\n}", 100 | "description": "Snippet for if else" 101 | }, 102 | "if err != nil": { 103 | "prefix": "iferr", 104 | "body": "if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}", 105 | "description": "Snippet for if err != nil" 106 | }, 107 | "fmt.Println": { 108 | "prefix": "fp", 109 | "body": "fmt.Println(\"$1\")", 110 | "description": "Snippet for fmt.Println()" 111 | }, 112 | "fmt.Printf": { 113 | "prefix": "ff", 114 | "body": "fmt.Printf(\"$1\", ${2:var})", 115 | "description": "Snippet for fmt.Printf()" 116 | }, 117 | "log.Println": { 118 | "prefix": "lp", 119 | "body": "log.Println(\"$1\")", 120 | "description": "Snippet for log.Println()" 121 | }, 122 | "log.Printf": { 123 | "prefix": "lf", 124 | "body": "log.Printf(\"$1\", ${2:var})", 125 | "description": "Snippet for log.Printf()" 126 | }, 127 | "log variable content": { 128 | "prefix": "lv", 129 | "body": "log.Printf(\"${1:var}: %#+v\\\\n\", ${1:var})", 130 | "description": "Snippet for log.Printf() with variable content" 131 | }, 132 | "t.Log": { 133 | "prefix": "tl", 134 | "body": "t.Log(\"$1\")", 135 | "description": "Snippet for t.Log()" 136 | }, 137 | "t.Logf": { 138 | "prefix": "tlf", 139 | "body": "t.Logf(\"$1\", ${2:var})", 140 | "description": "Snippet for t.Logf()" 141 | }, 142 | "t.Logf variable content": { 143 | "prefix": "tlv", 144 | "body": "t.Logf(\"${1:var}: %#+v\\\\n\", ${1:var})", 145 | "description": "Snippet for t.Logf() with variable content" 146 | }, 147 | "make(...)": { 148 | "prefix": "make", 149 | "body": "make(${1:type}, ${2:0})", 150 | "description": "Snippet for make statement" 151 | }, 152 | "new(...)": { 153 | "prefix": "new", 154 | "body": "new(${1:type})", 155 | "description": "Snippet for new statement" 156 | }, 157 | "panic(...)": { 158 | "prefix": "pn", 159 | "body": "panic(\"$0\")", 160 | "description": "Snippet for panic" 161 | }, 162 | "http ResponseWriter *Request": { 163 | "prefix": "wr", 164 | "body": "${1:w} http.ResponseWriter, ${2:r} *http.Request", 165 | "description": "Snippet for http Response" 166 | }, 167 | "http.HandleFunc": { 168 | "prefix": "hf", 169 | "body": "${1:http}.HandleFunc(\"${2:/}\", ${3:handler})", 170 | "description": "Snippet for http.HandleFunc()" 171 | }, 172 | "http handler declaration": { 173 | "prefix": "hand", 174 | "body": "func $1(${2:w} http.ResponseWriter, ${3:r} *http.Request) {\n\t$0\n}", 175 | "description": "Snippet for http handler declaration" 176 | }, 177 | "http.Redirect": { 178 | "prefix": "rd", 179 | "body": "http.Redirect(${1:w}, ${2:r}, \"${3:/}\", ${4:http.StatusFound})", 180 | "description": "Snippet for http.Redirect()" 181 | }, 182 | "http.Error": { 183 | "prefix": "herr", 184 | "body": "http.Error(${1:w}, ${2:err}.Error(), ${3:http.StatusInternalServerError})", 185 | "description": "Snippet for http.Error()" 186 | }, 187 | "http.ListenAndServe": { 188 | "prefix": "las", 189 | "body": "http.ListenAndServe(\"${1::8080}\", ${2:nil})", 190 | "description": "Snippet for http.ListenAndServe" 191 | }, 192 | "http.Serve": { 193 | "prefix": "sv", 194 | "body": "http.Serve(\"${1::8080}\", ${2:nil})", 195 | "description": "Snippet for http.Serve" 196 | }, 197 | "goroutine anonymous function": { 198 | "prefix": "go", 199 | "body": "go func($1) {\n\t$0\n}($2)", 200 | "description": "Snippet for anonymous goroutine declaration" 201 | }, 202 | "goroutine function": { 203 | "prefix": "gf", 204 | "body": "go ${1:func}($0)", 205 | "description": "Snippet for goroutine declaration" 206 | }, 207 | "defer statement": { 208 | "prefix": "df", 209 | "body": "defer ${1:func}($0)", 210 | "description": "Snippet for defer statement" 211 | }, 212 | "test function": { 213 | "prefix": "tf", 214 | "body": "func Test$1(t *testing.T) {\n\t$0\n}", 215 | "description": "Snippet for Test function" 216 | }, 217 | "benchmark function": { 218 | "prefix": "bf", 219 | "body": "func Benchmark$1(b *testing.B) {\n\tfor ${2:i} := 0; ${2:i} < b.N; ${2:i}++ {\n\t\t$0\n\t}\n}", 220 | "description": "Snippet for Benchmark function" 221 | }, 222 | "example function": { 223 | "prefix": "ef", 224 | "body": "func Example$1() {\n\t$2\n\t//Output:\n\t$3\n}", 225 | "description": "Snippet for Example function" 226 | }, 227 | "table driven test": { 228 | "prefix": "tdt", 229 | "body": "func Test$1(t *testing.T) {\n\ttestCases := []struct {\n\t\tdesc\tstring\n\t\t$2\n\t}{\n\t\t{\n\t\t\tdesc: \"$3\",\n\t\t\t$4\n\t\t},\n\t}\n\tfor _, tC := range testCases {\n\t\tt.Run(tC.desc, func(t *testing.T) {\n\t\t\t$0\n\t\t})\n\t}\n}", 230 | "description": "Snippet for table driven test" 231 | }, 232 | "init function": { 233 | "prefix": "finit", 234 | "body": "func init() {\n\t$1\n}", 235 | "description": "Snippet for init function" 236 | }, 237 | "main function": { 238 | "prefix": "fmain", 239 | "body": "func main() {\n\t$1\n}", 240 | "description": "Snippet for main function" 241 | }, 242 | "method declaration": { 243 | "prefix": "meth", 244 | "body": "func (${1:receiver} ${2:type}) ${3:method}($4) $5 {\n\t$0\n}", 245 | "description": "Snippet for method declaration" 246 | }, 247 | "hello world web app": { 248 | "prefix": "helloweb", 249 | "body": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc greet(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello World! %s\", time.Now())\n}\n\nfunc main() {\n\thttp.HandleFunc(\"/\", greet)\n\thttp.ListenAndServe(\":8080\", nil)\n}", 250 | "description": "Snippet for sample hello world webapp" 251 | }, 252 | "sort implementation": { 253 | "prefix": "sort", 254 | "body": "type ${1:SortBy} []${2:Type}\n\nfunc (a $1) Len() int { return len(a) }\nfunc (a $1) Swap(i, j int) { a[i], a[j] = a[j], a[i] }\nfunc (a $1) Less(i, j int) bool { ${3:return a[i] < a[j]} }", 255 | "description": "Snippet for a custom sort.Sort interface implementation, for a given slice type." 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /lua/wind/core/nav.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | My function to help navigation in vim 3 | --]] 4 | local windutils = import('core.utils') 5 | 6 | local M = {} 7 | 8 | local function is_qf_open() 9 | local winCount = vim.fn.winnr('$') 10 | for i = 1, winCount, 1 do 11 | local buffnr = vim.fn.winbufnr(i) 12 | if vim.fn.getbufvar(buffnr, '&filetype') == 'qf' then 13 | return true 14 | end 15 | end 16 | return false 17 | end 18 | 19 | local function is_buffer_fugitive(bufnr) 20 | bufnr = bufnr or vim.fn.bufnr('%') 21 | local bufname = vim.fn.bufname(bufnr) 22 | if string.match(bufname, "^fugitive") ~= nil then 23 | return true 24 | end 25 | return false 26 | end 27 | 28 | -- jump back or next buffer 29 | -- if qf is open it will use qf 30 | M.goto_buff_or_qf = function (command) 31 | if is_qf_open() then 32 | if is_buffer_fugitive() then 33 | local view = vim.fn.winsaveview() 34 | -- change to quickfix target 35 | -- clear old error message 36 | vim.cmd("echo ") 37 | vim.cmd("c"..command) 38 | vim.fn.winrestview(view) 39 | else 40 | vim.cmd("c"..command) 41 | end 42 | return 43 | else 44 | -- change back to buffer 45 | vim.cmd("b"..command) 46 | end 47 | end 48 | 49 | -- auto close if it display 2 buffer in diffrent tab file 50 | -- you can display 2 buffer in same tab. 51 | function M.on_buffer_open(bufnr) 52 | bufnr = tonumber(bufnr) 53 | local bufname = vim.fn.bufname(bufnr) 54 | if bufname == nil or string.len(bufname) < 2 then 55 | return 56 | end 57 | if 58 | string.match(bufname, "^fugitive") ~= nil 59 | or string.match(bufname, "^octo") ~= nil 60 | then 61 | return 62 | end 63 | 64 | local windows = vim.fn.win_findbuf(bufnr) 65 | local winnr = vim.fn.win_getid() 66 | local tabnr = vim.api.nvim_win_get_tabpage(winnr) 67 | if #windows >= 2 then 68 | for _, windowId in pairs(windows) do 69 | local cbuff = vim.api.nvim_win_get_buf(windowId) 70 | local ctab = vim.api.nvim_win_get_tabpage(windowId) 71 | local cname = vim.fn.bufname(cbuff) 72 | if windowId~= winnr and cname == bufname and ctab~= tabnr then 73 | vim.cmd(":q") 74 | vim.fn.win_gotoid(windowId) 75 | return 76 | end 77 | end 78 | end 79 | end 80 | 81 | function M.get_first_win_id_by_buf(bufnr, wid) 82 | local windows = vim.fn.win_findbuf(bufnr) 83 | for _, id in pairs(windows) do 84 | if id ~= wid then return id end 85 | end 86 | return nil 87 | end 88 | 89 | function M.get_bufnr_filename(filename) 90 | local bufname=vim.fn.bufname(filename) 91 | if filename == nil or string.len(bufname)==0 then 92 | return nil 93 | end 94 | local bufnr = vim.fn.bufnr(bufname) 95 | return bufnr 96 | end 97 | function M.get_window_id(filename) 98 | local bufname=vim.fn.bufname(filename) 99 | if filename == nil or string.len(bufname)==0 then 100 | return 101 | end 102 | local bufnr = vim.fn.bufnr(bufname) 103 | local window = vim.fn.win_findbuf(bufnr) 104 | if not vim.tbl_isempty(window) then 105 | return window[1] 106 | end 107 | end 108 | 109 | -- this function help jump to an exists buffer visible in window or different 110 | -- tab. The problem of vim is navigate between buffer it is different with vs code 111 | -- if you open 2 buffer in 2 window. You use gd to navigate to another 112 | -- function in another buffer it will change current buffer and you have 2 113 | -- buffer display same file 114 | -- work well with same window but not working with different 115 | -- tab open (Vim have different jumplists window and tab) 116 | 117 | function M.wind_open(arr) 118 | if type(arr) == 'string' then 119 | arr = {arr} 120 | end 121 | if vim.tbl_isempty(arr) then 122 | return 123 | end 124 | local filename = arr[1] 125 | -- match filename 126 | filename = string.gsub(filename, "file://" , '' ) 127 | filename = string.gsub(filename, "%%40" , '@' ) 128 | filename = string.gsub(filename, "%%20" , ' ' ) 129 | local cwd = vim.fn.expand("%:h") 130 | if cwd == "" then cwd = "." end 131 | filename = string.gsub(filename, [[^%./]] , cwd .. "/" ) 132 | 133 | if string.match(filename ,[[^../]]) ~= nil then 134 | filename = vim.fn.expand("%:h").."/"..filename 135 | end 136 | if vim.fn.filereadable(filename) == 0 then 137 | filename = vim.fn.expand(filename) 138 | end 139 | 140 | if vim.fn.filereadable(filename) == 0 then 141 | local check=false 142 | for _, value in pairs(vim.fn.split(vim.bo.suffixesadd,",")) do 143 | if vim.fn.filereadable(filename..value) == 1 then 144 | filename = filename..value 145 | check = true 146 | end 147 | end 148 | if check == false then 149 | local expr = vim.bo.includeexpr 150 | if string.len(expr)>1 then 151 | expr = string.gsub(expr, "v:fname", "'" .. filename .. "'" ) 152 | filename = vim.fn.eval(expr) end 153 | end 154 | if check == false then 155 | filename = string.gsub(filename, "^([a-zA-Z])", vim.fn.expand("%:h") .. "/%1") 156 | for _, value in pairs(vim.fn.split(vim.bo.suffixesadd,",")) do 157 | if vim.fn.filereadable(filename..value) == 1 then 158 | filename = filename..value 159 | check = true 160 | end 161 | end 162 | end 163 | if vim.fn.filereadable(filename) == 0 then 164 | print("error can't get file name " .. filename) 165 | return 166 | end 167 | end 168 | 169 | local windowId = M.get_window_id(filename) 170 | local bufnr = vim.fn.bufnr('%') 171 | local curpos = vim.fn.getpos('.') 172 | if windowId and windowId > 0 then 173 | vim.fn.win_gotoid(windowId) 174 | else 175 | vim.cmd('edit '..vim.fn.fnameescape(filename)) 176 | end 177 | 178 | -- my code for add another tab jump list 179 | if #arr>2 then 180 | local tabJumps = Wind.state.tab_jumps or {} 181 | local nlnum = tonumber(arr[2]) 182 | local ncol = tonumber(arr[3]) 183 | local tabData={ 184 | bufnr = bufnr, 185 | lnum = curpos[2], 186 | col = curpos[3], 187 | nlnum = nlnum , 188 | ncol = ncol, 189 | nbufnr = vim.fn.bufnr('%'), 190 | } 191 | tabJumps = vim.tbl_filter(function(value) 192 | if value.nbufnr == tabData.nbufnr and value.nlnum == tabData.nlnum then 193 | return false 194 | end 195 | return true 196 | end,tabJumps) 197 | table.insert(tabJumps, tabData) 198 | Wind.state.tab_jumps = tabJumps 199 | vim.api.nvim_win_set_cursor(0,{nlnum, ncol}) 200 | if arr[4] == nil then 201 | vim.api.nvim_command[[execute "normal! m` "]] 202 | end 203 | end 204 | end 205 | 206 | M.go_back = function() 207 | local cursor_pos = vim.fn.getpos(".") 208 | local bufnr = vim.fn.bufnr('%') 209 | local tabJumps = Wind.state.tab_jumps 210 | if tabJumps ~= nil then 211 | for index, jumpPos in pairs(tabJumps) do 212 | if jumpPos.nbufnr == bufnr and jumpPos.nlnum == cursor_pos[2] then 213 | local lnum= jumpPos.lnum 214 | local col = jumpPos.col + 1 215 | local cwId = vim.fn.win_getid() 216 | local windowId = M.get_first_win_id_by_buf(jumpPos.bufnr, cwId) 217 | if windowId ~= nil and windowId > 0 and cwId~=windowId then 218 | if vim.fn.win_gotoid(windowId) == 1 then 219 | vim.fn.cursor(lnum, col - 1) 220 | Wind.state.tab_jumps = windutils.remove_by_index(tabJumps, index) 221 | return 222 | end 223 | elseif jumpPos.bufnr > 0 and jumpPos.bufnr ~= bufnr and vim.fn.bufexists(jumpPos.bufnr) > 0 then 224 | vim.cmd("buffer" .. jumpPos.bufnr) 225 | vim.fn.cursor(lnum, col -1) 226 | Wind.state.tab_jumps = windutils.remove_by_index(tabJumps, index) 227 | return 228 | end 229 | end 230 | end 231 | end 232 | vim.cmd[[execute "normal! \zz"]] 233 | end 234 | 235 | M.wind_quit = function() 236 | 237 | end 238 | 239 | function M.sys_open(url) 240 | if Wind.is_linux then 241 | vim.cmd("silent !xdg-open '".. url .."'") 242 | else 243 | vim.cmd("silent !open ".. url) 244 | end 245 | end 246 | 247 | -- I disable netrw but still need open url by gx 248 | function M.open_or_search (isVisual) 249 | local url= '' 250 | if isVisual == 1 then 251 | url = windutils.get_visual_selection() 252 | url = "https://google.com/search?q="..url 253 | else 254 | local urlregex=[[https://[a-zA-Z0-9\?\.\/\#\_\-]*]] 255 | local line =vim.fn.getline('.') 256 | url = string.match(line , urlregex) 257 | if url~= nil then url = url:gsub("#" , "\\#") end 258 | if vim.fn.empty(url) == 1 then 259 | url = "https://google.com/search?q="..line 260 | end 261 | end 262 | M.sys_open(url) 263 | end 264 | 265 | Wind.wind_open = M.wind_open 266 | Wind.go_back = M.go_back 267 | 268 | return M 269 | -------------------------------------------------------------------------------- /autoload/win.vim: -------------------------------------------------------------------------------- 1 | "" Name: autoload/win.vim 2 | "" Author: Maxim Kim 3 | "" Desc: Windows manipulation functions. 4 | 5 | 6 | "" Delete all(saved) but visible buffers 7 | func! win#delete_buffers() 8 | let l:buffers = filter(getbufinfo(), {_, v -> v.hidden}) 9 | if !empty(l:buffers) 10 | execute 'bwipeout' join(map(l:buffers, {_, v -> v.bufnr})) 11 | endif 12 | endfunc 13 | 14 | 15 | "" Scroll other(previous) window 16 | func! win#scroll_other(dir) abort 17 | if winnr('$') < 2 18 | return 19 | endif 20 | wincmd p 21 | let cmd = "normal ".winheight(0) 22 | if a:dir 23 | let cmd .= "\" 24 | else 25 | let cmd .= "\" 26 | endif 27 | exe cmd 28 | wincmd p 29 | endfunc 30 | 31 | 32 | "" Autosize windows. 33 | "" There is lens.vim plugin but essentially this simplified version could be used 34 | "" instead. Original lens.vim laaaags if switched to a huge file, it 35 | "" calculates target width consuming whole file into memory.... 36 | "" 37 | "" Add following lines somewhere in your vimrc: 38 | "" augroup autosize_windows | au! 39 | "" au BufWinEnter,WinEnter * silent! call win#lens() 40 | "" augroup end 41 | let g:lens_block_next = 0 42 | func! win#lens() abort 43 | if s:is_lens_disabled() 44 | " when come back from floating window we don't update it 45 | " it happen with completin nvim 46 | let g:lens_block_next = 1 47 | return 48 | endif 49 | if g:lens_block_next == 1 50 | let g:lens_block_next = 0 51 | return 52 | end 53 | 54 | let default_width = s:win_default_width(80) 55 | 56 | let width = max([ 57 | \ get(g:, "lens_pref_width", default_width), 58 | \ winwidth(0) 59 | \ ]) 60 | let height = max([ 61 | \ get(g:, "lens_pref_height", 20), 62 | \ winheight(0) 63 | \ ]) 64 | 65 | execute printf('vertical resize %s', width) 66 | execute printf('resize %s', height) 67 | call s:fix_w_h(1) 68 | wincmd = 69 | call s:fix_w_h(0) 70 | normal! ze 71 | endfunction 72 | 73 | 74 | "" Return width of a signcolumn 75 | func! s:signcolumn_width() abort 76 | let sc = matchlist(&signcolumn, '\(yes\|auto\)\%(:\(\d\)\)\?') 77 | 78 | if empty(sc) 79 | return 0 80 | endif 81 | 82 | if sc[1] == "yes" 83 | return (sc[2] == '' ? 2 : sc[2]) 84 | endif 85 | 86 | if sc[1] == "auto" && !empty(sign_getplaced("%")[0].signs) 87 | return (sc[2] == '' ? 2 : sc[2]) 88 | endif 89 | endfunc 90 | 91 | 92 | "" Return default window width (including linenr and signcolumn) 93 | func! s:win_default_width(width) abort 94 | let width = a:width 95 | if &number || &relativenumber 96 | let width += max([strlen(line('$')), &numberwidth]) 97 | endif 98 | if &foldcolumn 99 | let width += max([1, &foldcolumn]) 100 | endif 101 | let width += s:signcolumn_width() 102 | return width 103 | endfunc 104 | 105 | 106 | func! s:is_lens_disabled() abort 107 | " do not resize floating windows 108 | if exists('*nvim_win_get_config') 109 | if nvim_win_get_config(0)['relative'] != '' 110 | return v:true 111 | endif 112 | endif 113 | 114 | " do not resize windows with filetype 115 | if index(get(g:, "lens_disabled_filetypes", []), &filetype) != -1 116 | return v:true 117 | endif 118 | 119 | if get(w:, 'resize_active', 0) == 1 120 | return v:true 121 | endif 122 | 123 | return v:false 124 | endfunc 125 | 126 | 127 | func! s:fix_w_h(val) 128 | call setwinvar(winnr(), "&winfixwidth", a:val) 129 | call setwinvar(winnr(), "&winfixheight", a:val) 130 | for w in range(1, winnr('$')) 131 | let ft = getbufvar(winbufnr(w), "&filetype", "") 132 | if index(get(g:, "lens_disabled_filetypes", []), ft) != -1 133 | call setwinvar(w, "&winfixwidth", a:val) 134 | call setwinvar(w, "&winfixheight", a:val) 135 | endif 136 | endfor 137 | endfunc 138 | 139 | 140 | "" 5 layouts 141 | "" layout 1: even horizontal 142 | "" layout 2: even vertical 143 | "" layout 3: main horizontal 144 | "" layout 4: main vertical 145 | "" layout 5: tiled 146 | func! win#layout_toggle() abort 147 | if winnr('$') == 1 148 | return "Single window" 149 | endif 150 | 151 | if winnr('$') == 2 152 | let win_layouts = 153 | \ {1: {"f": "win#layout_horizontal", "next": 2} 154 | \ ,2: {"f": "win#layout_vertical", "next": 1} 155 | \ } 156 | elseif winnr('$') == 3 157 | let win_layouts = 158 | \ {1: {"f": "win#layout_horizontal", "next": 2} 159 | \ ,2: {"f": "win#layout_vertical", "next": 3} 160 | \ ,3: {"f": "win#layout_main_horizontal", "next": 4} 161 | \ ,4: {"f": "win#layout_main_vertical", "next": 1} 162 | \ } 163 | else 164 | let win_layouts = 165 | \ {1: {"f": "win#layout_horizontal", "next": 2} 166 | \ ,2: {"f": "win#layout_vertical", "next": 3} 167 | \ ,3: {"f": "win#layout_main_horizontal", "next": 4} 168 | \ ,4: {"f": "win#layout_main_vertical", "next": 5} 169 | \ ,5: {"f": "win#layout_tile", "next": 1} 170 | \ } 171 | endif 172 | 173 | let layout_echo = "" 174 | let layout = min([get(t:, "window_layout", len(win_layouts)), len(win_layouts)]) 175 | 176 | 177 | let layout_echo = function(win_layouts[layout].f)() 178 | let t:window_layout = win_layouts[layout].next 179 | 180 | call win#lens() 181 | 182 | return layout_echo 183 | endfunc 184 | 185 | 186 | func! win#layout_horizontal() abort 187 | let winid = win_getid() 188 | windo wincmd L 189 | call win_gotoid(winid) 190 | wincmd H 191 | return "Even horizontal layout" 192 | endfunc 193 | 194 | 195 | func! win#layout_vertical() abort 196 | let winid = win_getid() 197 | windo wincmd K 198 | call win_gotoid(winid) 199 | wincmd K 200 | return "Even vertical layout" 201 | endfunc 202 | 203 | 204 | func! win#layout_main_horizontal() abort 205 | let winid = win_getid() 206 | windo wincmd L 207 | call win_gotoid(winid) 208 | wincmd K 209 | return "Main horizontal layout" 210 | endfunc 211 | 212 | 213 | func! win#layout_main_vertical() abort 214 | let winid = win_getid() 215 | windo wincmd K 216 | call win_gotoid(winid) 217 | wincmd H 218 | return "Main vertical layout" 219 | endfunc 220 | 221 | 222 | func! win#layout_tile() abort 223 | let windows = [] 224 | let buffers = [] 225 | 226 | for w in range(1, winnr('$')) 227 | if w != winnr() 228 | call add(buffers, winbufnr(w)) 229 | endif 230 | endfor 231 | 232 | silent only 233 | call add(windows, win_getid()) 234 | 235 | let half = len(buffers)/2 236 | 237 | let splitbelow = &splitbelow 238 | let splitright = &splitright 239 | try 240 | setl splitbelow 241 | setl splitright 242 | 243 | for bnr in range(half) 244 | split 245 | call add(windows, win_getid()) 246 | silent exe printf("buffer %s", buffers[bnr]) 247 | endfor 248 | 249 | let win_idx = 0 250 | for bnr in range(half, len(buffers) - 1) 251 | silent call win_gotoid(windows[win_idx]) 252 | vsplit 253 | silent exe printf("buffer %s", buffers[bnr]) 254 | 255 | let win_idx += 1 256 | endfor 257 | 258 | silent call win_gotoid(windows[0]) 259 | finally 260 | let &splitbelow = splitbelow 261 | let &splitright = splitright 262 | endtry 263 | 264 | return "Tiled layout" 265 | endfunc 266 | 267 | 268 | 269 | """ Zoom window: save and restore window layout 270 | "" nnoremap o :call win#zoom_toggle() 271 | "" o zoom window (there should be only 1 window) 272 | "" o restores previous windows 273 | func! win#zoom_toggle() abort 274 | if winnr('$') == 1 && get(t:, "zoomed", v:false) 275 | call s:layout_restore() 276 | let t:zoomed = v:false 277 | else 278 | let t:zoomed = v:true 279 | call s:layout_save() 280 | silent wincmd o 281 | endif 282 | endfunc 283 | 284 | 285 | func! s:layout_save(...) abort 286 | let t:zoom_winrestcmd = winrestcmd() 287 | let t:zoom_layout = winlayout() 288 | let t:zoom_cursor = [winnr(), getcurpos()] 289 | call s:add_buf_to_layout(t:zoom_layout) 290 | endfunc 291 | 292 | 293 | func! s:layout_restore() abort 294 | if empty(get(t:, "zoom_layout", [])) 295 | return 296 | endif 297 | 298 | " Close other windows 299 | silent wincmd o 300 | 301 | " recursively restore buffers 302 | call s:apply_layout(get(t:, "zoom_layout")) 303 | 304 | " resize 305 | exe t:zoom_winrestcmd 306 | 307 | " goto saved window 308 | exe printf("%dwincmd w", t:zoom_cursor[0]) 309 | 310 | " set cursor 311 | call setpos('.', t:zoom_cursor[1]) 312 | endfunc 313 | 314 | 315 | " add bufnr to leaf 316 | func! s:add_buf_to_layout(layout) abort 317 | if a:layout[0] ==# 'leaf' 318 | " replace win_id with buffer number 319 | let a:layout[1] = winbufnr(a:layout[1]) 320 | else 321 | for child_layout in a:layout[1] 322 | call s:add_buf_to_layout(child_layout) 323 | endfor 324 | endif 325 | endfunc 326 | 327 | 328 | func! s:apply_layout(layout) abort 329 | if a:layout[0] ==# 'leaf' 330 | " load buffer for leaf 331 | if bufexists(a:layout[1]) 332 | exe printf('b %d', a:layout[1]) 333 | endif 334 | else 335 | " split cols or rows, split n-1 times 336 | let split_method = a:layout[0] ==# 'col' ? 'rightbelow split' : 'rightbelow vsplit' 337 | let wins = [win_getid()] 338 | for child_layout in a:layout[1][1:] 339 | exe split_method 340 | let wins += [win_getid()] 341 | endfor 342 | 343 | " recursive into child windows 344 | for index in range(len(wins) ) 345 | call win_gotoid(wins[index]) 346 | call s:apply_layout(a:layout[1][index]) 347 | endfor 348 | endif 349 | endfunc 350 | -------------------------------------------------------------------------------- /lua/wind/plug/telescope.lua: -------------------------------------------------------------------------------- 1 | local actions = require('telescope.actions') 2 | local action_state = require('telescope.actions.state') 3 | local finders = require('telescope.finders') 4 | local make_entry = require('telescope.make_entry') 5 | local pickers = require('telescope.pickers') 6 | local previewers = require('telescope.previewers') 7 | local builtin = require('telescope.builtin') 8 | local conf = require('telescope.config').values 9 | local themes=require('telescope.themes') 10 | local flatten = vim.tbl_flatten 11 | require'telescope'.load_extension('gh') 12 | require'telescope'.load_extension('media_files') 13 | 14 | local nnoremap = import'core.keymap'.nnoremap 15 | local wind_open = import'core.nav'.wind_open 16 | -- require('telescope').load_extension('fzy_native') 17 | -- Global remapping 18 | ------------------------------ 19 | require('telescope').setup{ 20 | -- extensions = { 21 | -- fzy_native = { 22 | -- override_generic_sorter = false, 23 | -- override_file_sorter = true, 24 | -- } 25 | -- }, 26 | defaults = { 27 | color_devicons= true, 28 | vimgrep_arguments = { 29 | 'ag', 30 | '--column', 31 | '--numbers', 32 | '--noheading', 33 | '--nocolor', 34 | '--smart-case', 35 | '--ignore', 36 | 'yarn.lock', 37 | '--ignore', 38 | 'package-lock.json', 39 | }, 40 | mappings = { 41 | i= { 42 | [""] = actions.move_selection_next, 43 | [""] = actions.move_selection_previous, 44 | [""] = actions.select_vertical, 45 | [""] = actions.select_tab, 46 | [''] = actions.send_to_qflist, 47 | [''] = actions.toggle_selection, 48 | [""] = actions.close 49 | }, 50 | n = { 51 | [""] = actions.close 52 | }, 53 | }, 54 | }, 55 | } 56 | 57 | local M={} 58 | M.root = '' 59 | ------------------------------ 60 | local k_mappings= function(prompt_bufnr) 61 | actions.select_default:replace(function() 62 | local entry = action_state.get_selected_entry() 63 | actions.close(prompt_bufnr) 64 | if entry.col and entry.lnum and not entry[1] then 65 | -- mark current cursor open to jumplist 66 | vim.api.nvim_command[[execute "normal! m` "]] 67 | vim.fn.cursor(entry.lnum,entry.col) 68 | vim.api.nvim_feedkeys('zz','n',true) 69 | elseif entry[1] then 70 | local sections = vim.split(entry[1], ":") 71 | local filename = sections[1] 72 | filename = M.root..filename; 73 | local row = tonumber(sections[2]) 74 | local col = tonumber(sections[3]) 75 | -- mark current cursor open to jumplist 76 | vim.api.nvim_command[[execute "normal! m` "]] 77 | if row and col then 78 | wind_open({filename,row,col}) 79 | vim.fn.cursor(row,col) 80 | -- center position 81 | vim.api.nvim_feedkeys('zz','n',true) 82 | else 83 | wind_open({filename,row,col}) 84 | 85 | end 86 | end 87 | end) 88 | 89 | return true 90 | end 91 | 92 | function M.goto_definition(opts) 93 | opts = opts or {} 94 | local params = vim.lsp.util.make_position_params() 95 | -- print(vim.inspect(params)) 96 | -- need to process when it have multiple result and multiple language server 97 | local results_lsp = vim.lsp.buf_request_sync(0, "textDocument/definition", params, opts.timeout or 10000) 98 | if not results_lsp or vim.tbl_isempty(results_lsp) then 99 | print("No results from textDocument/definition") 100 | return 101 | end 102 | for _, lsp_data in pairs(results_lsp) do 103 | if lsp_data ~= nil and lsp_data.result ~= nil and not vim.tbl_isempty(lsp_data.result) then 104 | for _, value in pairs(lsp_data.result) do 105 | local range = value.range or value.targetRange 106 | if range ~= nil then 107 | local line = range.start.line 108 | local character = range.start.character 109 | local file = value.uri or value.targetUri 110 | -- skipp node module 111 | -- if file ~=nil and not string.match(file,'node_modules') then 112 | if file ~=nil then 113 | -- mark current cursor open to jumplist 114 | vim.api.nvim_command[[execute "normal! m` "]] 115 | wind_open({file , line + 1 , character + 1}) 116 | vim.fn.cursor(line + 1 , character + 1) 117 | vim.api.nvim_feedkeys('zz','n',true) 118 | return 119 | end 120 | end 121 | end 122 | end 123 | end 124 | -- try to call default lsp function 125 | vim.lsp.buf.definition() 126 | end 127 | 128 | 129 | function M.picker_codeaction(opts) 130 | opts = opts or {} 131 | opts = themes.get_dropdown(opts) 132 | opts.previewer = false 133 | opts.width = nil 134 | builtin.lsp_code_actions(opts) 135 | end 136 | 137 | function M.picker_current_folder(opts) 138 | opts = opts or {} 139 | opts.cwd = "%:p:h" 140 | opts.tilte = "" 141 | M.file_picker(opts) 142 | end 143 | 144 | 145 | function M.picker_buffers(opts) 146 | opts = opts or {} 147 | opts = themes.get_dropdown(opts) 148 | opts.previewer = false 149 | opts.width = nil 150 | builtin.buffers(opts) 151 | end 152 | 153 | function M.picker_oldfiles(opts) 154 | opts = opts or {} 155 | opts.shorten_path = true 156 | opts = themes.get_dropdown(opts) 157 | opts.width = nil 158 | opts.previewer = false 159 | builtin.oldfiles(opts) 160 | end 161 | function M.picker_document_symbol(opts) 162 | opts = opts or {} 163 | opts = themes.get_dropdown(opts) 164 | opts.previewer = false 165 | opts.hide_filename = true 166 | opts.attach_mappings = k_mappings 167 | builtin.lsp_document_symbols(opts) 168 | end 169 | local function closeFern() 170 | if vim.bo.filetype == 'fern' then 171 | vim.cmd(":q") 172 | end 173 | end 174 | 175 | function M.live_grep() 176 | closeFern() 177 | builtin.live_grep() 178 | end 179 | 180 | function M.git_picker(opts) 181 | closeFern() 182 | M.root='' 183 | opts = opts or {} 184 | opts.title = '' 185 | opts = themes.get_dropdown(opts) 186 | opts.width = nil 187 | opts.attach_mappings = k_mappings 188 | if opts.cwd then 189 | opts.cwd = vim.fn.expand(opts.cwd) 190 | M.root = opts.cwd ..'/' 191 | opts.title = opts.cwd 192 | end 193 | opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts) 194 | pickers.new(opts, { 195 | prompt_title = 'Git File', 196 | finder = finders.new_oneshot_job( 197 | { "git", "ls-files", "--exclude-standard", "--cached", "--others" }, 198 | opts 199 | ), 200 | previewer = false, 201 | sorter = conf.file_sorter(opts), 202 | }):find() 203 | end 204 | function M.file_picker(opts) 205 | closeFern() 206 | M.root='' 207 | opts = opts or {} 208 | opts.title = '' 209 | opts = themes.get_dropdown(opts) 210 | opts.width = nil 211 | opts.attach_mappings = k_mappings 212 | if opts.cwd then 213 | opts.cwd = vim.fn.expand(opts.cwd) 214 | M.root = opts.cwd ..'/' 215 | opts.title=opts.cwd 216 | end 217 | 218 | if not opts.cwd and vim.fn.expand("%:p:h") == vim.fn.expand("~") then 219 | print("We don't search in home directory") 220 | return 221 | end 222 | local find_command = { "ag", "-g", ""} 223 | if vim.g.wind_use_agsort == 1 then 224 | find_command = { vim.fn.expand('$HOME/.config/nvim/scripts/agfile.sh'), vim.fn.expand('%') } 225 | end 226 | opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts) 227 | 228 | pickers.new(opts, { 229 | prompt_title = 'Find Files'..opts.title, 230 | finder = finders.new_oneshot_job( 231 | find_command, 232 | opts 233 | ), 234 | previewer = false, 235 | sorter = conf.file_sorter(opts), 236 | }):find() 237 | end 238 | 239 | 240 | 241 | 242 | function M.ag_find_filetype(opts) 243 | closeFern() 244 | opts = opts or {} 245 | opts.attach_mappings=k_mappings 246 | opts.shorten_path = true 247 | local filetype=vim.fn.input("Input file type : ") 248 | local vimgrep_arguments= { 249 | 'ag', 250 | '--column', 251 | '--numbers', 252 | '--noheading', 253 | '--nocolor', 254 | '--smart-case', 255 | '-G', 256 | '.*\\.' .. filetype 257 | } 258 | local live_grepper = finders.new_job(function(prompt) 259 | if not prompt or prompt == "" then 260 | return nil 261 | end 262 | -- print (table.tostring(flatten { vimgrep_arguments, prompt })) 263 | return flatten { vimgrep_arguments, prompt } 264 | end, 265 | opts.entry_maker or make_entry.gen_from_vimgrep(opts), 266 | opts.max_results 267 | ) 268 | 269 | pickers.new(opts, { 270 | prompt_title = 'Search file ' .. filetype, 271 | finder = live_grepper, 272 | previewer = previewers.vimgrep.new(opts), 273 | sorter = conf.generic_sorter(opts), 274 | }):find() 275 | end 276 | 277 | 278 | function M.ag_find_folder(opts) 279 | closeFern() 280 | opts = opts or {} 281 | opts.attach_mappings = k_mappings 282 | opts.cwd = opts.cwd or vim.fn.expand("%:p:h") 283 | opts.shorten_path = true 284 | require('telescope.builtin').live_grep(opts) 285 | end 286 | 287 | nnoremap({'' , 'lua Wind.load_plug("telescope").file_picker()' }) 288 | nnoremap({'p' , 'Telescope commands' }) 289 | nnoremap({'p' , 'Telescope commands' }) 290 | nnoremap({'f' , 'lua Wind.load_plug("telescope").live_grep()' }) 291 | nnoremap({'g;' , 'lua Wind.load_plug("telescope").picker_buffers()' }) 292 | nnoremap({'g,' , 'lua Wind.load_plug("telescope").picker_oldfiles()' }) 293 | 294 | vim.api.nvim_exec([[ 295 | command! -nargs=* SearchByFileType call v:lua.Wind.load_plug("telescope").ag_find_filetype() 296 | command! -nargs=* SearchCurrentFolder call v:lua.Wind.load_plug("telescope").ag_find_folder() 297 | command! -nargs=* LspCodeAction call v:lua.Wind.load_plug("telescope/builtin").lsp_range_code_actions() 298 | ]],false) 299 | 300 | import('general.autocmd').add_autocmd_color('telescope', function () 301 | vim.api.nvim_exec([[ 302 | highlight TelescopeSelection guifg=#9cf087 gui=bold guibg=#00384d 303 | highlight TelescopeSelectionCaret guifg=#9cf087 guibg=#00384d 304 | highlight TelescopeMultiSelection guifg=#928374 305 | highlight TelescopeNormal guibg=#00000 306 | highlight TelescopeMatching guifg=#ffcc1b 307 | highlight TelescopePromptPrefix guifg=#9cf087 308 | ]],false) 309 | end) 310 | 311 | return M 312 | 313 | -------------------------------------------------------------------------------- /lua/wind/plug/windline/comps.lua: -------------------------------------------------------------------------------- 1 | local helper = require('windline.helpers') 2 | local git_comps = require('windline.components.git') 3 | local basic_comps = require('windline.components.basic') 4 | local vim_comps = require('windline.components.vim') 5 | local lsp_comps = require('windline.components.lsp') 6 | local cache_utils = require('windline.cache_utils') 7 | local api = vim.api 8 | local sep = helper.separators 9 | 10 | local is_lsp = function () 11 | if vim.b.wind_lsp_server_name ~= nil 12 | and #vim.b.wind_lsp_server_name > 1 then 13 | return true 14 | end 15 | return false 16 | end 17 | 18 | local state = _G.WindLine.state 19 | 20 | local check_lsp_status = lsp_comps.check_custom_lsp({func_check = is_lsp}) 21 | 22 | local hl_list = { 23 | Black = {'white' , 'black' } , 24 | Inactive = {'InactiveFg' , 'InactiveBg' } , 25 | Left = {'LeftFg' , 'LeftBg' } , 26 | Right = {'RightFg' , 'RightBg' } , 27 | } 28 | 29 | local comps = {} 30 | 31 | comps.divider = {basic_comps.divider, ''} 32 | comps.space = {' ', ''} 33 | comps.line_col = {basic_comps.line_col,hl_list.Black } 34 | comps.progress = {basic_comps.progress, hl_list.Black} 35 | comps.bg = {" ", 'StatusLine'} 36 | comps.file_name_inactive = {basic_comps.full_file_name, hl_list.Inactive} 37 | comps.line_col_inactive = {basic_comps.line_col, hl_list.Inactive} 38 | comps.progress_inactive = {basic_comps.progress, hl_list.Inactive} 39 | 40 | comps.sep_second_left = {sep.slant_right_thin, ''} 41 | comps.sep_second_left_black = {sep.slant_right_thin, hl_list.Black} 42 | 43 | comps.file_modified_inactive = {basic_comps.file_modified, hl_list.Black} 44 | 45 | comps.vi_mode= { 46 | name='vi_mode', 47 | hl_colors = { 48 | Normal = {'white', 'black' } , 49 | Insert = {'white', 'blue_light' } , 50 | Visual = {'white', 'blue' } , 51 | Replace = {'black', 'green' } , 52 | Command = {'white', 'red' } , 53 | } , 54 | text = function() return ' ' .. state.mode[1] .. ' ' end, 55 | hl = function (hl_data) return hl_data[state.mode[2]] 56 | end, 57 | } 58 | 59 | comps.vi_mode_sep = { 60 | name='vi_mode_sep', 61 | hl_colors = { 62 | Normal = {'black', 'LeftBg'}, 63 | Insert = {'blue_light', 'LeftBg'}, 64 | Visual = {'blue', 'LeftBg'}, 65 | Replace = {'green', 'LeftBg'}, 66 | Command = {'red', 'LeftBg'}, 67 | } 68 | , 69 | text = function() return sep.slant_right end, 70 | hl = function (data) return data[state.mode[2]] end, 71 | } 72 | 73 | comps.alert_mode = { 74 | name = 'alert_mode', 75 | hl_colors = { 76 | default = {'white' , 'red' } , 77 | beforeEmpty = {'MiddleBg' , 'black' } , 78 | afterEmpty = {'black' , 'RightBg' } , 79 | after = {'red' , 'RightBg' } , 80 | before = {'MiddleBg' , 'red' } , 81 | bg = {'black' , 'green' } , 82 | red = {'red' , 'black' } , 83 | green = {'green' , 'black' } 84 | }, 85 | text = function () 86 | local text = '' 87 | if(vim.g.resize_active == 1) then text = ' Resize Mode ' end 88 | if(vim.g.ibus_engine_enable ==1 or vim.g.keymap_engine_enable == 1) then 89 | if state.mode[1] == 'INSERT' then 90 | text= ' [VN] ' 91 | else 92 | text = ' [EN] ' 93 | end 94 | end 95 | if text == '' then 96 | local sep_ani = Wind.state.animation and '' or sep.slant_right 97 | return { 98 | {sep_ani, 'beforeEmpty'}, 99 | {function() 100 | if vim.bo.modified or vim.bo.modifiable == false then 101 | return ' ⬤ ' 102 | end 103 | return'' 104 | end, 105 | function (hl_data) 106 | if not hl_data then return ' ' end 107 | if vim.bo.modified then 108 | return hl_data.green 109 | elseif vim.bo.modifiable == false or vim.bo.readonly == true then 110 | return hl_data.red 111 | end 112 | return hl_data.bg 113 | end}, 114 | {sep.slant_right, 'afterEmpty'}, 115 | } 116 | end 117 | return { 118 | {sep.slant_right, 'before'}, 119 | {text, 'default'}, 120 | {sep.slant_right, 'after'}, 121 | } 122 | end 123 | } 124 | comps.git_status = { 125 | text = git_comps.git_branch(), 126 | hl_colors = hl_list.Left 127 | } 128 | 129 | 130 | comps.file_name = { 131 | text = basic_comps.cache_file_name('','unique'), 132 | hl_colors = {'LeftFg','LeftBg' } 133 | } 134 | 135 | 136 | comps.lsp_status = { 137 | name = "lsp_status", 138 | hl_colors = { 139 | default = {'RightFg', 'RightBg'}, 140 | red = {'red', 'RightBg'}, 141 | sep = {'RightBg', 'black'} 142 | } , 143 | text = cache_utils.cache_on_buffer('BufEnter','wl_lsp_status',function() 144 | local file_name, file_ext = vim.fn.expand("%:t"), vim.fn.expand("%:e") 145 | local icon = helper.get_icon(file_name, file_ext) 146 | if is_lsp() then 147 | return { 148 | {icon .. ' ' .. vim.b.wind_lsp_server_name,'default'}, 149 | {sep.slant_right, 'sep'} 150 | } 151 | end 152 | local filetype = vim.bo.filetype 153 | if filetype == "" then 154 | return { 155 | {"  ", 'default'}, 156 | {sep.slant_right, 'sep'} 157 | } 158 | end 159 | local text = string.format(" %s %s ", icon, filetype):lower() 160 | local hl = Wind.is_dev and 'red' or 'default' 161 | return { 162 | { text, hl}, 163 | {sep.slant_right, 'sep'} 164 | } 165 | end), 166 | } 167 | 168 | local search_count = vim_comps.search_count() 169 | comps.search_count={ 170 | hl_colors={ 171 | search = {'black', 'yellow'}, 172 | default = {'black', 'white'}, 173 | sep_before = {'black', 'yellow'}, 174 | sep_after = {'yellow', 'LeftBg'} 175 | }, 176 | text = function() 177 | local count = search_count() 178 | if count and #count > 1 then 179 | if not check_lsp_status() then 180 | return { 181 | { count, 'default'}, 182 | { sep.slant_right_thin,''} 183 | } 184 | end 185 | return { 186 | {sep.slant_right, 'sep_before'}, 187 | { count, 'search'}, 188 | {sep.slant_right,'sep_after'} 189 | } 190 | end 191 | return nil 192 | end 193 | } 194 | comps.lsp_diagnos = { 195 | name = 'diagnostic', 196 | hl_colors = { 197 | default = {'black' , 'LeftBg' }, 198 | red = {'red' , 'black' }, 199 | yellow = {'yellow' , 'black' }, 200 | sep_after = {'black' , 'LeftBg' }, 201 | sep_before = {'black' , 'LeftBg' }, 202 | }, 203 | text = function () 204 | local c_lsp_status = check_lsp_status() 205 | local count = search_count() 206 | local sep_after = sep.slant_right 207 | if count and #count >1 then 208 | sep_after = '' 209 | end 210 | if c_lsp_status then 211 | return{ 212 | {sep.slant_left, 'sep_before'} , 213 | {string.format("  %s", state.comp.lsp_error or 0), 'red'}, 214 | {string.format("  %s ", state.comp.lsp_warning or 0), 'yellow'}, 215 | {sep_after, 'sep_after' }, 216 | } 217 | end 218 | if git_comps.is_git() then 219 | return {{ sep.slant_right_thin, 'default'}} 220 | end 221 | return '' 222 | end, 223 | } 224 | 225 | comps.explorer_name = { 226 | name = 'explorer_name', 227 | text = function(bufnr) 228 | if bufnr == nil then return '' end 229 | local bufname = vim.fn.expand(vim.fn.bufname(bufnr)) 230 | local _,_, bufnamemin = string.find(bufname,[[%/([^%/]*%/[^%/]*);?%$$]]) 231 | if bufnamemin ~= nil and #bufnamemin > 1 then return bufnamemin end 232 | return bufname 233 | end, 234 | hl_colors = {'black', 'MiddleBg'} 235 | } 236 | 237 | comps.terminal_name = { 238 | text = function(bufnr) 239 | if bufnr == nil then return '' end 240 | bufnr = tonumber(bufnr) 241 | local bufname = vim.fn.expand(vim.fn.bufname(bufnr)) 242 | return bufname:sub(#bufname -11,#bufname) 243 | end, 244 | hl_colors = hl_list.Inactive 245 | } 246 | 247 | comps.terminal_mode = { 248 | name='terminal', 249 | text = function () 250 | if 251 | vim.g.statusline_winid == api.nvim_get_current_win() 252 | and state.mode[1] == 'TERMINAL' 253 | then 254 | return { 255 | {' ⚡ ', function(hl_data) return hl_data[state.mode[2]] end}, 256 | {sep.slant_right, 'sep'} 257 | } 258 | end 259 | return { 260 | {' ⚡ ','empty'} 261 | } 262 | end, 263 | hl_colors = { 264 | sep = {'blue_light', 'InactiveBg'}, 265 | Normal = {'MiddleFg', 'MiddleBg' } , 266 | Command = {'black', 'blue_light' } , 267 | empty = {'white', 'black'}, 268 | }, 269 | } 270 | 271 | 272 | comps.wave_left={ 273 | hl_colors = { 274 | wave_blue1 = {'LeftBg', 'waveleft1'}, 275 | wave_blue2 = {'waveleft1', 'waveleft2'}, 276 | wave_blue3 = {'waveleft2', 'waveleft3'}, 277 | wave_blue4 = {'waveleft3', 'waveleft4'}, 278 | wave_blue5 = {'waveleft4', 'waveleft5'}, 279 | wave_blue6 = {'waveleft5', 'MiddleBg'}, 280 | default = {'LeftBg', 'MiddleBg'} 281 | }, 282 | text = function() 283 | if Wind.state.animation == true then 284 | return { 285 | {sep.slant_right .. ' ', 'wave_blue1'}, 286 | {sep.slant_right .. ' ', 'wave_blue2'}, 287 | {sep.slant_right .. ' ', 'wave_blue3'}, 288 | {sep.slant_right .. ' ', 'wave_blue4'}, 289 | {sep.slant_right .. ' ', 'wave_blue5'}, 290 | {sep.slant_right .. ' ', 'wave_blue6'}, 291 | } 292 | end 293 | return { 294 | {sep.slant_right , 'default'}, 295 | } 296 | end, 297 | } 298 | 299 | comps.wave_right={ 300 | hl_colors = { 301 | wave_blue1 = { 'MiddleBg' ,'waveright1',} , 302 | wave_blue2 = { 'waveright1','waveright2',} , 303 | wave_blue3 = { 'waveright2','waveright3',} , 304 | wave_blue4 = { 'waveright3','waveright4',} , 305 | wave_blue5 = { 'waveright4','waveright5',} , 306 | wave_blue6 = { 'waveright5','black' ,} , 307 | default = {'MiddleBg' , 'MiddleBg' } , 308 | }, 309 | text = function() 310 | if Wind.state.animation == true then 311 | return { 312 | {sep.slant_right.. ' ' , 'wave_blue1'}, 313 | {sep.slant_right.. ' ' , 'wave_blue2'}, 314 | {sep.slant_right.. ' ' , 'wave_blue3'}, 315 | {sep.slant_right.. ' ' , 'wave_blue4'}, 316 | {sep.slant_right.. ' ' , 'wave_blue5'}, 317 | {sep.slant_right.. '' , 'wave_blue6'}, 318 | } 319 | end 320 | return '' 321 | end 322 | } 323 | return comps 324 | 325 | -------------------------------------------------------------------------------- /snippets/dart.json: -------------------------------------------------------------------------------- 1 | { 2 | "Stateless Widget": { 3 | "prefix": "statelessW", 4 | "body": [ 5 | "class ${1:name} extends StatelessWidget {", 6 | " const ${1:name}({Key key}) : super(key: key);\n", 7 | " @override", 8 | " Widget build(BuildContext context) {", 9 | " return Container(", 10 | " child: ${2:child},", 11 | " );", 12 | " }", 13 | "}" 14 | ], 15 | "description": "Create a Stateless widget" 16 | }, 17 | "Stateful Widget": { 18 | "prefix": "statefulW", 19 | "body": [ 20 | "class ${1:name} extends StatefulWidget {", 21 | " ${1:name}({Key key}) : super(key: key);\n", 22 | " @override", 23 | " _${1:WidgetName}State createState() => _${1:WidgetName}State();", 24 | "}\n", 25 | "class _${1:index}State extends State<${1:index}> {", 26 | " @override", 27 | " Widget build(BuildContext context) {", 28 | " return Container(", 29 | " child: ${2:child},", 30 | " );", 31 | " }", 32 | "}" 33 | ], 34 | "description": "Create a Stateful widget" 35 | }, 36 | "Build Method": { 37 | "prefix": "build", 38 | "body": [ 39 | "@override", 40 | "Widget build(BuildContext context) {", 41 | " return ${0:};", 42 | "}" 43 | ], 44 | "description": "Describes the part of the user interface represented by this widget." 45 | }, 46 | "Custom Painter ": { 47 | "prefix": "customPainter", 48 | "body": [ 49 | "class ${0:name}Painter extends CustomPainter {", 50 | "", 51 | " @override", 52 | " void paint(Canvas canvas, Size size) {", 53 | " }", 54 | "", 55 | " @override", 56 | " bool shouldRepaint(${0:name}Painter oldDelegate) => false;", 57 | "", 58 | " @override", 59 | " bool shouldRebuildSemantics(${0:name}Painter oldDelegate) => false;", 60 | "}" 61 | ], 62 | "description": "Used for creating custom paint" 63 | }, 64 | "Custom Clipper ": { 65 | "prefix": "customClipper", 66 | "body": [ 67 | "class ${0:name}Clipper extends CustomClipper {", 68 | "", 69 | " @override", 70 | " Path getClip(Size size) {", 71 | " }", 72 | "", 73 | " @override", 74 | " bool shouldReclip(CustomClipper oldClipper) => false;", 75 | "}" 76 | ], 77 | "description": "Used for creating custom shapes" 78 | }, 79 | "InitState ": { 80 | "prefix": "initS", 81 | "body": [ 82 | "@override", 83 | "void initState() { ", 84 | " super.initState();", 85 | " ${0:}", 86 | "}" 87 | ], 88 | "description": "Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates." 89 | }, 90 | "Dispose": { 91 | "prefix": "dis", 92 | "body": [ 93 | "@override", 94 | "void dispose() { ", 95 | " ${0:}", 96 | " super.dispose();", 97 | "}" 98 | ], 99 | "description": "Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again." 100 | }, 101 | "Reassemble": { 102 | "prefix": "reassemble", 103 | "body": [ 104 | "@override", 105 | "void reassemble(){", 106 | " super.reassemble();", 107 | " ${0:}", 108 | "}" 109 | ], 110 | "description": "Called whenever the application is reassembled during debugging, for example during hot reload." 111 | }, 112 | "didChangeDependencies": { 113 | "prefix": "didChangeD", 114 | "body": [ 115 | "@override", 116 | "void didChangeDependencies() {", 117 | " super.didChangeDependencies();", 118 | " ${0:}", 119 | "}" 120 | ], 121 | "description": "Called when a dependency of this State object changes" 122 | }, 123 | "didUpdateWidget": { 124 | "prefix": "didUpdateW", 125 | "body": [ 126 | "@override", 127 | "void didUpdateWidget (${1:Type} ${2:oldWidget}) {", 128 | " super.didUpdateWidget(${2:oldWidget});", 129 | " ${0:}", 130 | "}" 131 | ], 132 | "description": "Called whenever the widget configuration changes." 133 | }, 134 | "ListView.Builder": { 135 | "prefix": "listViewB", 136 | "body": [ 137 | "ListView.builder(", 138 | " itemCount: ${1:1},", 139 | " itemBuilder: (BuildContext context, int index) {", 140 | " return ${2:};", 141 | " },", 142 | ")," 143 | ], 144 | "description": "Creates a scrollable, linear array of widgets that are created on demand.Providing a non-null `itemCount` improves the ability of the [ListView] to estimate the maximum scroll extent." 145 | }, 146 | "ListView.Separated": { 147 | "prefix": "listViewS", 148 | "body": [ 149 | "ListView.separated(", 150 | " itemCount: ${1:1},", 151 | " separatorBuilder: (BuildContext context, int index) {", 152 | " return ${2:};", 153 | " },", 154 | " itemBuilder: (BuildContext context, int index) {", 155 | " return ${3:};", 156 | " },", 157 | ")," 158 | ], 159 | "description": "Creates a fixed-length scrollable linear array of list 'items' separated by list item 'separators'." 160 | }, 161 | "Custom Scroll View": { 162 | "prefix": "customScrollV", 163 | "body": [ 164 | "CustomScrollView(", 165 | " slivers: [", 166 | " ${0:}", 167 | " ],", 168 | ")," 169 | ], 170 | "description": "Creates a `ScrollView` that creates custom scroll effects using slivers. If the `primary` argument is true, the `controller` must be null." 171 | }, 172 | "Stream Builder": { 173 | "prefix": "streamBldr", 174 | "body": [ 175 | "StreamBuilder(", 176 | " stream: ${1:stream} ,", 177 | " initialData: ${2:initialData} ,", 178 | " builder: (BuildContext context, AsyncSnapshot snapshot){", 179 | " return Container(", 180 | " child: ${3:child},", 181 | " );", 182 | " },", 183 | ")," 184 | ], 185 | "description": "Creates a new `StreamBuilder` that builds itself based on the latest snapshot of interaction with the specified `stream`" 186 | }, 187 | "Animated Builder": { 188 | "prefix": "animatedBldr", 189 | "body": [ 190 | "AnimatedBuilder(", 191 | " animation: ${1:animation},", 192 | " child: ${2:child},", 193 | " builder: (BuildContext context, Widget child) {", 194 | " return ${3:};", 195 | " },", 196 | ")," 197 | ], 198 | "description": "Creates an Animated Builder. The widget specified to `child` is passed to the `builder` " 199 | }, 200 | "Stateful Builder": { 201 | "prefix": "statefulBldr", 202 | "body": [ 203 | "StatefulBuilder(", 204 | " builder: (BuildContext context, setState) {", 205 | " return ${0:};", 206 | " },", 207 | ")," 208 | ], 209 | "description": "Creates a widget that both has state and delegates its build to a callback. Useful for rebuilding specific sections of the widget tree." 210 | }, 211 | "Orientation Builder": { 212 | "prefix": "orientationBldr", 213 | "body": [ 214 | "OrientationBuilder(", 215 | " builder: (BuildContext context, Orientation orientation) {", 216 | " return Container(", 217 | " child: ${3:child},", 218 | " );", 219 | " },", 220 | ")," 221 | ], 222 | "description": "Creates a builder which allows for the orientation of the device to be specified and referenced" 223 | }, 224 | "Layout Builder": { 225 | "prefix": "layoutBldr", 226 | "body": [ 227 | "LayoutBuilder(", 228 | " builder: (BuildContext context, BoxConstraints constraints) {", 229 | " return ${0:};", 230 | " },", 231 | ")," 232 | ], 233 | "description": "Similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints." 234 | }, 235 | "Single Child ScrollView": { 236 | "prefix": "singleChildSV", 237 | "body": [ 238 | "SingleChildScrollView(", 239 | " controller: ${1:controller,}", 240 | " child: Column(", 241 | " ${0:}", 242 | " ),", 243 | ")," 244 | ], 245 | "description": "Creates a scroll view with a single child" 246 | }, 247 | "Future Builder": { 248 | "prefix": "futureBldr", 249 | "body": [ 250 | "FutureBuilder(", 251 | " future: ${1:Future},", 252 | " initialData: ${2:InitialData},", 253 | " builder: (BuildContext context, AsyncSnapshot snapshot) {", 254 | " return ${3:};", 255 | " },", 256 | ")," 257 | ], 258 | "description": "Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future." 259 | }, 260 | "No Such Method": { 261 | "prefix": "nosm", 262 | "body": [ 263 | "@override", 264 | "dynamic noSuchMethod(Invocation invocation) {", 265 | " ${1:}", 266 | "}" 267 | ], 268 | "description": "This method is invoked when a non-existent method or property is accessed." 269 | }, 270 | "Inherited Widget": { 271 | "prefix": "inheritedW", 272 | "body": [ 273 | "class ${1:Name} extends InheritedWidget {", 274 | " ${1:Name}({Key key, this.child}) : super(key: key, child: child);", 275 | "", 276 | " final Widget child;", 277 | "", 278 | " static ${1:Name} of(BuildContext context) {", 279 | " return context.dependOnInheritedWidgetOfExactType<${1:Name}>();", 280 | " }", 281 | "", 282 | " @override", 283 | " bool updateShouldNotify(${1:Name} oldWidget) {", 284 | " return ${2:true};", 285 | " }", 286 | "}" 287 | ], 288 | "description": "Class used to propagate information down the widget tree" 289 | }, 290 | "Mounted": { 291 | "prefix": "mounted", 292 | "body": [ 293 | "@override", 294 | "bool get mounted {", 295 | " ${0:}", 296 | "}" 297 | ], 298 | "description": "Whether this State object is currently in a tree." 299 | }, 300 | "Sink": { 301 | "prefix": "snk", 302 | "body": [ 303 | "Sink<${1:type}> get ${2:name} => _${2:name}Controller.sink;", 304 | "final _${2:name}Controller = StreamController<${1:type}>();" 305 | ], 306 | "description": "A Sink is the input of a stream." 307 | }, 308 | "Stream": { 309 | "prefix": "strm", 310 | "body": [ 311 | "Stream<${1:type}> get ${2:name} => _${2:name}Controller.stream;", 312 | "final _${2:name}Controller = StreamController<${1:type}>();" 313 | ], 314 | "description": "A source of asynchronous data events. A stream can be of any data type " 315 | }, 316 | "Subject": { 317 | "prefix": "subj", 318 | "body": [ 319 | "Stream<${1:type}> get ${2:name} => _${2:name}Subject.stream;", 320 | "final _${2:name}Subject = BehaviorSubject<${1:type}>();" 321 | ], 322 | "description": "A BehaviorSubject is also a broadcast StreamController which returns an Observable rather than a Stream." 323 | }, 324 | "toString": { 325 | "prefix": "toStr", 326 | "body": [ 327 | "@override", 328 | "String toString() {", 329 | "return ${1:toString};", 330 | " }" 331 | ], 332 | "description": "Returns a string representation of this object." 333 | }, 334 | "debugPrint": { 335 | "prefix": "debugP", 336 | "body": [ 337 | "debugPrint(${1:statement});" 338 | ], 339 | "description": "Prints a message to the console, which you can access using the flutter tool's `logs` command (flutter logs)." 340 | }, 341 | "Material Package": { 342 | "prefix": "importM", 343 | "body": "import 'package:flutter/material.dart';", 344 | "description": "Import flutter material package" 345 | }, 346 | "Cupertino Package": { 347 | "prefix": "importC", 348 | "body": "import 'package:flutter/cupertino.dart';", 349 | "description": "Import Flutter Cupertino package" 350 | }, 351 | "flutter_test Package": { 352 | "prefix": "importFT", 353 | "body": "import 'package:flutter_test/flutter_test.dart';", 354 | "description": "Import flutter_test package" 355 | }, 356 | "Material App": { 357 | "prefix": "mateapp", 358 | "description": "Create a MaterialApp", 359 | "body": [ 360 | "import 'package:flutter/material.dart';", 361 | " ", 362 | "void main() => runApp(MyApp());", 363 | " ", 364 | "class MyApp extends StatelessWidget {", 365 | " @override", 366 | " Widget build(BuildContext context) {", 367 | " return MaterialApp(", 368 | " title: 'Material App',", 369 | " home: Scaffold(", 370 | " appBar: AppBar(", 371 | " title: Text('Material App Bar'),", 372 | " ),", 373 | " body: Center(", 374 | " child: Container(", 375 | " child: Text('Hello World'),", 376 | " ),", 377 | " ),", 378 | " ),", 379 | " );", 380 | " }", 381 | "}" 382 | ] 383 | }, 384 | "Cupertino App": { 385 | "prefix": "cupeapp", 386 | "description": "Cupertino App", 387 | "body": [ 388 | "import 'package:flutter/cupertino.dart';", 389 | " ", 390 | "void main() => runApp(MyApp());", 391 | " ", 392 | "class MyApp extends StatelessWidget {", 393 | " @override", 394 | " Widget build(BuildContext context) {", 395 | " return CupertinoApp(", 396 | " title: 'Cupertino App',", 397 | " home: CupertinoPageScaffold(", 398 | " navigationBar: CupertinoNavigationBar(", 399 | " middle: Text('Cupertino App Bar'),", 400 | " ),", 401 | " child: Center(", 402 | " child: Container(", 403 | " child: Text('Hello World'),", 404 | " ),", 405 | " ),", 406 | " ),", 407 | " );", 408 | " }", 409 | "}" 410 | ] 411 | }, 412 | "Tween Animation Builder": { 413 | "prefix": "tweenAnimationBuilder", 414 | "body": [ 415 | "TweenAnimationBuilder(", 416 | " duration: ${1:const Duration(),}", 417 | " tween: ${2:Tween(),}", 418 | " builder: (BuildContext context, ${3:dynamic} value, Widget child) {", 419 | " return ${4:Container();}", 420 | " },", 421 | " ), " 422 | ], 423 | "description": "Widget builder that animates a property of a Widget to a target value whenever the target value changes." 424 | }, 425 | "Value Listenable Builder": { 426 | "prefix": "valueListenableBuilder", 427 | "body": [ 428 | "ValueListenableBuilder(", 429 | " valueListenable: ${1: null},", 430 | " builder: (BuildContext context, ${2:dynamic} value, Widget child) {", 431 | " return ${3: Container();}", 432 | " },", 433 | " )," 434 | ], 435 | "description": "Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes." 436 | }, 437 | "Test": { 438 | "prefix": "f-test", 439 | "body": [ 440 | "test(", 441 | " \"${1:test description}\",", 442 | " () {},", 443 | ");" 444 | ], 445 | "description": "Create a test function" 446 | }, 447 | "Test Widgets": { 448 | "prefix": "widgetTest", 449 | "body": [ 450 | "testWidgets(", 451 | " \"${1:test description}\",", 452 | " (WidgetTester tester) async {},", 453 | ");" 454 | ], 455 | "description": "Create a testWidgets function" 456 | } 457 | } 458 | --------------------------------------------------------------------------------