├── README.md ├── autoload ├── fullscreen.vim └── fullscreen │ └── emulator.vim ├── doc └── vim-fullscreen.txt └── plugin └── fullscreen.vim /README.md: -------------------------------------------------------------------------------- 1 | vim-fullscreen 2 | ================== 3 | ![Version 1.2.1](https://img.shields.io/badge/version-1.2.1-yellow.svg?style=flat-square) 4 | ![Support Vim 7.4 or above](https://img.shields.io/badge/support-Vim%207.4%20or%20above-yellowgreen.svg?style=flat-square) 5 | [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE) 6 | [![Doc](https://img.shields.io/badge/doc-%3Ah%20vim--fullscreen-orange.svg?style=flat-square)](doc/vim-fullscreen.txt) 7 | 8 | *vim-fullscreen* is a plugin which help users to toggle a fullscreen mode on 9 | GVim or MacVim. 10 | 11 | Requirements 12 | --------------- 13 | 14 | ### MacVim requirements 15 | vim-fullscreen is ready to use. 16 | 17 | ### X11 requirements 18 | vim-fullscreen use 19 | [wmctrl](http://tomas.styblo.name/wmctrl/) to enable fullscreen. 20 | Thus you should use the software with: 21 | 22 | ```sh 23 | $ sudo apt-get install wmctrl # Ubuntu/Debian 24 | $ sudo yum install wmctrl # CentOS 25 | ``` 26 | 27 | ### Windows requirements 28 | vim-fullscreen works as an emulator mode which assign 999 to `columns` and `lines`. 29 | 30 | 31 | Install 32 | ---------- 33 | Use your favorite Vim plugin manager such as [junegunn/vim-plug] or [Shougo/dein.vim] like: 34 | 35 | ```vim 36 | " Plug.vim 37 | Plug 'lambdalisue/vim-fullscreen' 38 | 39 | " dein.vim 40 | call dein#add('lambdalisue/vim-fullscreen') 41 | 42 | " dein.vim (lazy) 43 | call dein#add('lambdalisue/vim-fullscreen', { 44 | \ 'on_cmd': [ 45 | \ 'FullscreenStart', 46 | \ 'FullscreenStop', 47 | \ 'FullscreenToggle', 48 | \ ], 49 | \}) 50 | ``` 51 | 52 | Or copy contents of the repository into your runtimepath manually. 53 | 54 | [junegunn/vim-plug]: https://github.com/junegunn/vim-plug 55 | [Shougo/dein.vim]: https://github.com/Shougo/dein.vim 56 | 57 | 58 | Usage 59 | ---------- 60 | Hit `Ctrl + Return` to toggle a fullscreen mode (in default mapping). 61 | Or execute `:FullscreenToggle` command. 62 | 63 | 64 | Tips 65 | ---------- 66 | 67 | ### With neovim-qt 68 | 69 | vim-fullscreen can toggle [neovim-qt](https://github.com/equalsraf/neovim-qt) with the following configuration. 70 | 71 | ```vim 72 | " In ginit.vim 73 | let g:fullscreen#start_command = "call rpcnotify(0, 'Gui', 'WindowFullScreen', 1)" 74 | let g:fullscreen#stop_command = "call rpcnotify(0, 'Gui', 'WindowFullScreen', 0)" 75 | ``` 76 | 77 | Documents 78 | ---------- 79 | See `:help vim-fullscreen` 80 | 81 | 82 | License 83 | ------------------------------------------------------------------------------- 84 | The MIT License (MIT) 85 | 86 | Copyright (c) 2014-2016 Alisue, hashnote.net 87 | 88 | Permission is hereby granted, free of charge, to any person obtaining a copy 89 | of this software and associated documentation files (the "Software"), to deal 90 | in the Software without restriction, including without limitation the rights 91 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 92 | copies of the Software, and to permit persons to whom the Software is 93 | furnished to do so, subject to the following conditions: 94 | 95 | The above copyright notice and this permission notice shall be included in 96 | all copies or substantial portions of the Software. 97 | 98 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 99 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 100 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 101 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 102 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 103 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 104 | THE SOFTWARE. 105 | -------------------------------------------------------------------------------- /autoload/fullscreen.vim: -------------------------------------------------------------------------------- 1 | "============================================================================== 2 | " vim-fullscreen 3 | " 4 | " Use GVim/MacVim in fullscreen mode 5 | " 6 | " Author: Alsiue 7 | " License: MIT license 8 | "============================================================================== 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | function! s:wmctrl(mod) abort 13 | call system(printf( 14 | \ '%s -r :ACTIVE: -b %s,fullscreen', 15 | \ g:fullscreen#wmctrl_exec, 16 | \ a:mod 17 | \ )) 18 | redraw! 19 | endfunction 20 | 21 | function! fullscreen#start() abort 22 | if exists('g:fullscreen#start_callback_pre') 23 | execute g:fullscreen#start_callback_pre 24 | endif 25 | let g:fullscreen#status = 1 26 | if exists('g:fullscreen#start_command') 27 | execute g:fullscreen#start_command 28 | elseif has('gui_macvim') 29 | set fullscreen 30 | elseif executable(g:fullscreen#wmctrl_exec) 31 | call s:wmctrl('add') 32 | else 33 | call fullscreen#emulator#start() 34 | endif 35 | if exists('g:fullscreen#start_callback_post') 36 | execute g:fullscreen#start_callback_post 37 | endif 38 | endfunction 39 | 40 | function! fullscreen#stop() abort 41 | if exists('g:fullscreen#stop_callback_pre') 42 | execute g:fullscreen#stop_callback_pre 43 | endif 44 | let g:fullscreen#status = 0 45 | if exists('g:fullscreen#stop_command') 46 | execute g:fullscreen#stop_command 47 | elseif has('gui_macvim') 48 | set nofullscreen 49 | elseif executable(g:fullscreen#wmctrl_exec) 50 | call s:wmctrl('remove') 51 | else 52 | call fullscreen#emulator#stop() 53 | endif 54 | if exists('g:fullscreen#stop_callback_post') 55 | execute g:fullscreen#stop_callback_post 56 | endif 57 | endfunction 58 | 59 | function! fullscreen#toggle() abort 60 | if exists('g:fullscreen#toggle_callback_pre') 61 | execute g:fullscreen#toggle_callback_pre 62 | endif 63 | let g:fullscreen#status = get(g:, 'fullscreen#status', 0) 64 | if g:fullscreen#status == 0 65 | call fullscreen#start() 66 | else 67 | call fullscreen#stop() 68 | endif 69 | if exists('g:fullscreen#toggle_callback_post') 70 | execute g:fullscreen#toggle_callback_post 71 | endif 72 | endfunction 73 | 74 | "============================================================================== 75 | " Configuration 76 | 77 | let s:settings = { 78 | \ 'wmctrl_exec': '"wmctrl"', 79 | \ 'auto_config_fuoptions': 1, 80 | \ } 81 | 82 | "============================================================================== 83 | " Initialization 84 | " 85 | function! s:init() abort 86 | for [key, val] in items(s:settings) 87 | if !exists('g:fullscreen#' . key) 88 | exe 'let g:fullscreen#' . key . ' = ' . val 89 | endif 90 | endfor 91 | if g:fullscreen#auto_config_fuoptions == 1 && has('gui_macvim') 92 | set fuoptions=maxvert,maxhorz 93 | endif 94 | endfunction 95 | 96 | call s:init() 97 | 98 | let &cpo = s:save_cpo 99 | unlet! s:save_cpo 100 | "vim: foldlevel=0 sts=2 sw=2 smarttab et ai textwidth=0 fdm=marker 101 | -------------------------------------------------------------------------------- /autoload/fullscreen/emulator.vim: -------------------------------------------------------------------------------- 1 | "============================================================================== 2 | " fullscreen emulator 3 | " 4 | " Emulate fullscreen mode without wmctrl. 5 | " 6 | " Ref: https://github.com/lambdalisue/vim-fullscreen/issues/3 7 | " Author: Alsiue 8 | " License: MIT license 9 | "============================================================================== 10 | let s:save_cpo = &cpo 11 | set cpo&vim 12 | 13 | "============================================================================== 14 | " Functions 15 | 16 | function! fullscreen#emulator#start() 17 | if g:fullscreen#emulator#auto_config_guioptions == 1 18 | let s:go_temp = &guioptions 19 | set guioptions-=m 20 | set guioptions-=T 21 | endif 22 | if has('win32') || has('win64') 23 | " maximize the window size (Alt Space x) 24 | simalt ~x 25 | else 26 | " store the current lines and columns 27 | let [s:lines_save, s:columns_save] = [&lines, &columns] 28 | 29 | " emulate the fullscreen 30 | " Note: 31 | " This strategy does not work correctly on dual monitor. 32 | " However, this is a just emulator thus I think in that case users 33 | " should user wmctrl or so on. 34 | set columns=999 35 | set lines=999 36 | endif 37 | endfunction 38 | 39 | function! fullscreen#emulator#stop() 40 | if g:fullscreen#emulator#auto_config_guioptions == 1 41 | if exists('s:go_temp') 42 | if s:go_temp =~# 'm' 43 | set guioptions+=m 44 | endif 45 | if s:go_temp =~# 'T' 46 | set guioptions+=T 47 | endif 48 | endif 49 | endif 50 | if has('win32') || has('win64') 51 | " revert the window size (Alt Space r) 52 | simalt ~r 53 | else 54 | " restore the lines and columns 55 | let [&lines, &columns] = [s:lines_save, s:columns_save] 56 | endif 57 | endfunction 58 | 59 | "============================================================================== 60 | " Configuration 61 | 62 | let s:settings = { 63 | \ 'auto_config_guioptions': 1, 64 | \ } 65 | 66 | "============================================================================== 67 | " Initialization 68 | " 69 | function! s:init() 70 | for [key, val] in items(s:settings) 71 | if !exists('g:fullscreen#emulator#' . key) 72 | exe 'let g:fullscreen#emulator#' . key . ' = ' . val 73 | endif 74 | endfor 75 | endfunction 76 | 77 | call s:init() 78 | 79 | let &cpo = s:save_cpo 80 | unlet! s:save_cpo 81 | "vim: foldlevel=0 sts=2 sw=2 smarttab et ai textwidth=0 fdm=marker 82 | -------------------------------------------------------------------------------- /doc/vim-fullscreen.txt: -------------------------------------------------------------------------------- 1 | *vim-fullscreen.txt* Help to toggle a fullscreen mode on GVim/MacVim 2 | 3 | Version: 1.2 4 | Author: Alisue *vim-fullscreen-author* 5 | Support: Vim 7.4 and above 6 | License: MIT license 7 | 8 | Copyright (c) 2014-2016 Alisue, hashnote.net 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining 11 | a copy of this software and associated documentation files 12 | (the "Software"), to deal in the Software without restriction, 13 | including without limitation the rights to use, copy, modify, merge, 14 | publish, distribute, sublicense, and/or sell copies of the Software, 15 | and to permit persons to whom the Software is furnished to do so, 16 | subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be 19 | included in all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 25 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 26 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | 29 | 30 | ============================================================================= 31 | CONTENTS *vim-fullscreen-contents* 32 | 33 | Introduction |vim-fullscreen-introduction| 34 | Usage |vim-fullscreen-usage| 35 | Requirements |vim-fullscreen-requirements| 36 | Install 'wmctrl' |vim-fullscreen-install-wmctrl| 37 | Interface |vim-fullscreen-interface| 38 | Commands |vim-fullscreen-commands| 39 | Functions |vim-fullscreen-functions| 40 | Configurations |vim-fullscreen-configurations| 41 | 42 | 43 | ============================================================================= 44 | INTRODUCTION *vim-fullscreen-introduction* 45 | 46 | *vim-fullscreen* is a plugin which help users to toggle a fullscreen mode on 47 | GVim or MacVim. This plugin use the following strategy to enable fullscreen 48 | mode: 49 | 50 | - MacVim |fullscreen| option 51 | - External window management program 'wmctrl' 52 | - Windows |simalt| command 53 | - |columns| and |lines| options 54 | 55 | 56 | ============================================================================= 57 | USAGE *vim-fullscreen-usage* 58 | 59 | Hit Ctrl + Return to toggle a fullscreen mode. This default keymap can be 60 | disabled with |g:fullscreen#enable_default_keymap| option. 61 | 62 | 63 | ============================================================================= 64 | REQUIREMENTS *vim-fullscreen-requirements* 65 | 66 | There are three options to enable fullscreen mode. 67 | 68 | 1. Use MacVim while it has a built-in fullscreen feature (recommended for Mac 69 | users) 70 | 2. Install an external command 'wmctrl' (http://tomas.styblo.name/wmctrl/) to 71 | manage Vim window (recommended for X11 users) 72 | 3. Use |vim-fullscreen| built-in emulator (recommended only for windows user) 73 | 74 | ----------------------------------------------------------------------------- 75 | INSTALL WMCTRL *vim-fullscreen-install-wmctrl* 76 | 77 | Numerous Linux distribution have 'wmctrl' in its package repository thus you 78 | probably can find the program with package management software such as 79 | 'apt-get' or 'yum'. 80 | 81 | Ubuntu/Debian: 82 | > 83 | sudo apt-get install wmctrl 84 | < 85 | Cent OS: 86 | > 87 | yum install wmctrl 88 | < 89 | 90 | ============================================================================= 91 | INTERFACE *vim-fullscreen-interface* 92 | 93 | ----------------------------------------------------------------------------- 94 | KEYMAPS *vim-fullscreen-keymaps* 95 | 96 | (fullscreen-start) *(fullscreen-start)* 97 | Start a fullscreen mode. It call |fullscreen#start()| internally. 98 | 99 | (fullscreen-stop) *(fullscreen-stop)* 100 | Stop a fullscreen mode. It call |fullscreen#stop()| internally. 101 | 102 | (fullscreen-toggle) *(fullscreen-toggle)* 103 | Toggle a fullscreen mode. It call |fullscreen#toggle()| internally. 104 | 105 | 106 | ----------------------------------------------------------------------------- 107 | COMMANDS *vim-fullscreen-commands* 108 | 109 | :FullscreenStart *:FullscreenStart* 110 | Start a fullscreen mode. It call |fullscreen#start()| internally. 111 | 112 | :FullscreenStop *:FullscreenStop* 113 | Stop a fullscreen mode. It call |fullscreen#stop()| internally. 114 | 115 | :FullscreenToggle *:FullscreenToggle* 116 | Toggle a fullscreen mode. It call |fullscreen#toggle()| internally. 117 | 118 | 119 | ----------------------------------------------------------------------------- 120 | FUNCTIONS *vim-fullscreen-functions* 121 | 122 | fullscreen#start() *fullscreen#start()* 123 | Start a fullscreen mode. This function automatically select the best way 124 | to enable the fullscreen if |g:fullscreen#start_command| is missing. 125 | Otherwise it executes the command. 126 | It will set |g:fullscreen#status| to 1. 127 | Additionally it will execute |g:fullscreen#start_callback_pre| and 128 | |g:fullscreen#start_callback_post| at before and after if any string is 129 | specified. 130 | 131 | 132 | fullscreen#stop() *fullscreen#stop()* 133 | Stop a fullscreen mode. This function automatically select the best way 134 | to disable the fullscreen if |g:fullscreen#stop_command| is missing. 135 | Otherwise it executes the command. 136 | It will set |g:fullscreen#status| to 0. 137 | Additionally it will execute |g:fullscreen#stop_callback_pre| and 138 | |g:fullscreen#stop_callback_post| at before and after if any string is 139 | specified. 140 | 141 | fullscreen#toggle() *fullscreen#toggle()* 142 | Toggle a fullscreen mode. It will call |fullscreen#start()| or 143 | |fullscreen#stop()| depends on |g:fullscreen#status| value. 144 | Additionally it will execute |g:fullscreen#toggle_callback_pre| and 145 | |g:fullscreen#toggle_callback_post| at before and after if any string is 146 | specified. 147 | 148 | 149 | ----------------------------------------------------------------------------- 150 | CONFIGURATION *vim-fullscreen-configuration* 151 | 152 | g:fullscreen#enable_default_keymap *g:fullscreen#enable_default_keymap* 153 | 154 | Enable a default key map. The default keymap is 155 | Default to 1. 156 | > 157 | nmap (fullscreen-toggle) 158 | < 159 | g:fullscreen#start_command *g:fullscreen#start_command* 160 | 161 | If any string is specified, the string will be executed by |execute| 162 | command to get in the fullscreen mode. 163 | > 164 | " e.g. neovim-qt 165 | let g:fullscreen#start_command = 166 | \ "call rpcnotify(0, 'Gui', 'WindowFullscreen', 1)" 167 | < 168 | g:fullscreen#stop_command *g:fullscreen#stop_command* 169 | 170 | If any string is specified, the string will be executed by |execute| 171 | command to get out from the fullscreen mode. 172 | > 173 | " e.g. neovim-qt 174 | let g:fullscreen#stop_command = 175 | \ "call rpcnotify(0, 'Gui', 'WindowFullscreen', 0)" 176 | < 177 | g:fullscreen#start_callback_pre *g:fullscreen#start_callback_pre* 178 | 179 | If any string is specified, the string will be executed by |execute| 180 | command before get in the fullscreen mode. 181 | 182 | g:fullscreen#stop_callback_pre *g:fullscreen#stop_callback_pre* 183 | 184 | If any string is specified, the string will be executed by |execute| 185 | command before get out the fullscreen mode. 186 | 187 | g:fullscreen#toggle_callback_pre *g:fullscreen#toggle_callback_pre* 188 | 189 | If any string is specified, the string will be executed by |execute| 190 | command before toggle the fullscreen mode. 191 | 192 | g:fullscreen#start_callback_post *g:fullscreen#start_callback_post* 193 | 194 | If any string is specified, the string will be executed by |execute| 195 | command after get in the fullscreen mode. 196 | 197 | g:fullscreen#stop_callback_post *g:fullscreen#stop_callback_post* 198 | 199 | If any string is specified, the string will be executed by |execute| 200 | command after get out the fullscreen mode. 201 | 202 | g:fullscreen#toggle_callback_post *g:fullscreen#toggle_callback_post* 203 | 204 | If any string is specified, the string will be executed by |execute| 205 | command after toggle the fullscreen mode. 206 | 207 | g:fullscreen#status *g:fullscreen#status* 208 | 209 | Represent the current status of a fullscreen mode. 210 | You should not change this value manually. 211 | 212 | *g:fullscreen#auto_config_fuoptions* 213 | g:fullscreen#auto_config_fuoptions 214 | 215 | 1 to automatically configure |fuoptions| at plugin loading. 216 | It will only affect when user use MacVim. 217 | Default to 1. 218 | 219 | *g:fullscreen#emulator#auto_config_guioptions* 220 | g:fullscreen#emulator#auto_config_guioptions 221 | 222 | 1 to automatically configure |guioptions| in fullscreen emulation mode. 223 | Default to 1. 224 | 225 | 226 | ============================================================================= 227 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 228 | -------------------------------------------------------------------------------- /plugin/fullscreen.vim: -------------------------------------------------------------------------------- 1 | "============================================================================== 2 | " vim-fullscreen 3 | " 4 | " Use GVim/MacVim in fullscreen mode 5 | " 6 | " Author: Alsiue 7 | " License: MIT license 8 | "============================================================================== 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | command! FullscreenStart call fullscreen#start() 13 | command! FullscreenStop call fullscreen#stop() 14 | command! FullscreenToggle call fullscreen#toggle() 15 | 16 | nnoremap (fullscreen-start) :call fullscreen#start() 17 | nnoremap (fullscreen-stop) :call fullscreen#stop() 18 | nnoremap (fullscreen-toggle) :call fullscreen#toggle() 19 | 20 | if get(g:, 'fullscreen#enable_default_keymap', 1) == 1 21 | nmap (fullscreen-toggle) 22 | endif 23 | 24 | let &cpo = s:save_cpo 25 | unlet! s:save_cpo 26 | "vim: foldlevel=0 sts=2 sw=2 smarttab et ai textwidth=0 fdm=marker 27 | --------------------------------------------------------------------------------