분할 창을 항상 잘 볼 수 있습니다
참고 : 참조를 위해이 스크린 캐스트에는 40 행과 120 개의 열로 설정된 치수가 있습니다.
여기에서 각 초점 기능의 시각적 데모를 참조하십시오 .
다음은 몇 가지 일반적인 설치 방법에 대한 코드 스 니펫입니다 (하나만 사용).
| Github Repo | 나뭇가지 | 코드 스 니펫 |
|---|---|---|
| 'Focus.nvim'라이브러리 | 기본 | { 'nvim-focus/focus.nvim', version = false }, |
| 안정적인 | { 'nvim-focus/focus.nvim', version = '*' }, |
| Github Repo | 나뭇가지 | 코드 스 니펫 |
|---|---|---|
| 'Focus.nvim'라이브러리 | 기본 | use 'nvim-focus/focus.nvim' |
| 안정적인 | use { 'nvim-focus/focus.nvim', branch = 'stable' } |
| Github Repo | 나뭇가지 | 코드 스 니펫 |
|---|---|---|
| 'Focus.nvim'라이브러리 | 기본 | Plug 'nvim-focus/focus.nvim' |
| 안정적인 | Plug("nvim-focus/focus.nvim", {["tag"]="stable"}) -- stable should be the latest stable version, as of 16th july 2024, it's v1.0.0 |
모든 배터리가 포함 된 기본 설정의 경우 다음이 포함됩니다.
require ( " focus " ). setup ()구성은 설정 함수로 전달 될 수 있습니다. 다음은 기본 설정이있는 예입니다.
require ( " focus " ). setup ({
enable = true , -- Enable module
commands = true , -- Create Focus commands
autoresize = {
enable = true , -- Enable or disable auto-resizing of splits
width = 0 , -- Force width for the focused window
height = 0 , -- Force height for the focused window
minwidth = 0 , -- Force minimum width for the unfocused window
minheight = 0 , -- Force minimum height for the unfocused window
height_quickfix = 10 , -- Set the height of quickfix panel
},
split = {
bufnew = false , -- Create blank buffer for new split windows
tmux = false , -- Create tmux splits instead of neovim splits
},
ui = {
number = false , -- Display line numbers in the focussed window only
relativenumber = false , -- Display relative line numbers in the focussed window only
hybridnumber = false , -- Display hybrid line numbers in the focussed window only
absolutenumber_unfocussed = false , -- Preserve absolute numbers in the unfocussed windows
cursorline = true , -- Display a cursorline in the focussed window only
cursorcolumn = false , -- Display cursorcolumn in the focussed window only
colorcolumn = {
enable = false , -- Display colorcolumn in the foccused window only
list = ' +1 ' , -- Set the comma-saperated list for the colorcolumn
},
signcolumn = true , -- Display signcolumn in the focussed window only
winhighlight = false , -- Auto highlighting for focussed/unfocussed windows
}
})참고 창보기를 관리하려면 크기를 조정할 때 다음을 참조하십시오
:h splitkeep.
Neovim> = 0.10 사용자의 경우splitkeep=cursor사용하는 것이 좋습니다.
Neovim <= 0.8 사용자의 경우 안정화 플러그인을 사용하는 것이 좋습니다. LazyVim 사용자의 경우 기본 옵션에서opt.winminwidth = 5설정하면 세션 관리 플러그인과 충돌 할 수 있습니다.
초점을 활성화/비활성화합니다
-- Completely disable this plugin
-- Default: true
require ( " focus " ). setup ({ enable = false })포커스 명령을 활성화/비활성화합니다
-- This not export :Focus* commands
-- Default: true
require ( " focus " ). setup ({ commands = false })초점 창 자동화를 활성화/비활성화합니다
-- The focussed window will no longer automatically resize. Other focus features are still available
-- Default: true
require ( " focus " ). setup ({ autoresize = { enable = false } })초점 너비를 설정하십시오
-- Force width for the focused window
-- Default: Calculated based on golden ratio
require ( " focus " ). setup ({ autoresize = { width = 120 } })초점 최소 너비를 설정하십시오
-- Force minimum width for the unfocused window
-- Default: Calculated based on golden ratio
require ( " focus " ). setup ({ autoresize = { minwidth = 80 } })초점 높이를 설정하십시오
-- Force height for the focused window
-- Default: Calculated based on golden ratio
require ( " focus " ). setup ({ autoresize = { height = 40 } })초점 최소 높이를 설정하십시오
-- Force minimum height for the unfocused window
-- Default: 0
require ( " focus " ). setup ({ autoresize = { minheight = 10 } })포커스 QuickFix 높이를 설정하십시오
-- Sets the height of quickfix panel, in case you pass the height to
-- `:copen <height>`
-- Default: 10
require ( " focus " ). setup ({ autoresize = { height_quickfix = 10 })새 분할 창을 만들 때 빈 버퍼로 초기화/하지 마십시오.
-- True: When a :Focus.. command creates a new split window, initialise it as a new blank buffer
-- False: When a :Focus.. command creates a new split, retain a copy of the current window in the new window
-- Default: false
require ( " focus " ). setup ({ split = { bufnew = true } })초점 자동 번호를 설정하십시오
-- Displays line numbers in the focussed window only
-- Not displayed in unfocussed windows
-- Default: true
require ( " focus " ). setup ({ ui = { number = false } })초점 자동 상대 번호를 설정하십시오
-- Displays relative line numbers in the focussed window only
-- Not displayed in unfocussed windows
-- See :help relativenumber
-- Default: false
require ( " focus " ). setup ({ ui = { relativenumber = true } })초점 자동 하이브리드 번호를 설정하십시오
-- Displays hybrid line numbers in the focussed window only
-- Not displayed in unfocussed windows
-- Combination of :help relativenumber, but also displays the line number of the
-- current line only
-- Default: false
require ( " focus " ). setup ({ ui = { hybridnumber = true } })절대 숫자를 유지하십시오
-- Preserve absolute numbers in the unfocussed windows
-- Works in combination with relativenumber or hybridnumber
-- Default: false
require ( " focus " ). setup ({ ui = { absolutenumber_unfocussed = true } })새 분할 창을 만들 때 neovim 대신 tmux 분할을 사용하십시오.
-- True: Create tmux splits instead of neovim splits
-- False: Create neovim split windows
-- Default: false
require ( " focus " ). setup ({ split = { tmux = true } })초점 자동 커서 라인을 설정하십시오
-- Displays a cursorline in the focussed window only
-- Not displayed in unfocussed windows
-- Default: true
require ( " focus " ). setup ({ ui = { cursorline = false } })초점 자동 커서 열을 설정하십시오
-- Displays a cursor column in the focussed window only
-- See :help cursorcolumn for more options
-- Default: false
require ( " focus " ). setup ({ ui = { cursorcolumn = true } })초점 자동 색상 열을 설정하십시오
-- Displays a color column in the focussed window only
-- See :help colorcolumn for more options
-- Default: enable = false, list = '+1'
require ( " focus " ). setup ({
ui = {
colorcolumn = {
enable = true ,
list = ' +1,+2 '
}
}
})초점 자동 부호 열을 설정하십시오
-- Displays a sign column in the focussed window only
-- Gets the vim variable setcolumn when focus.setup() is run
-- See :help signcolumn for more options e.g :set signcolum=yes
-- Default: true, signcolumn=auto
require ( " focus " ). setup ({ ui = { signcolumn = false } })포커스 창 하이라이트를 설정하십시오
-- Enable auto highlighting for focussed/unfocussed windows
-- Default: false
require ( " focus " ). setup ({ ui = { winhighlight = true } })
-- By default, the highlight groups are setup as such:
-- hi default link FocusedWindow VertSplit
-- hi default link UnfocusedWindow Normal
-- To change them, you can link them to a different highlight group, see
-- `:help hi-default` for more info.
vim . highlight . link ( ' FocusedWindow ' , ' CursorLine ' , true )
vim . highlight . link ( ' UnfocusedWindow ' , ' VisualNOS ' , true ) 하나의 창에 대한 변수를 설정하여 ( vim.w.focus_disable = true ), 단 하나의 버퍼 ( vim.b.focus_disable = true ) 또는 전역 ( vim.g.focus_disable = true )에 대한 변수를 설정하여 초점을 비활성화 할 수 있습니다.
특정 버퍼 또는 파일 유형에 대한 초점을 비활성화하려면 구성에서 자동 명령 ( :help autocmd )을 설정하여이를 수행 할 수 있습니다.
예는 다음과 같습니다.
local ignore_filetypes = { ' neo-tree ' }
local ignore_buftypes = { ' nofile ' , ' prompt ' , ' popup ' }
local augroup =
vim . api . nvim_create_augroup ( ' FocusDisable ' , { clear = true })
vim . api . nvim_create_autocmd ( ' WinEnter ' , {
group = augroup ,
callback = function ( _ )
if vim . tbl_contains ( ignore_buftypes , vim . bo . buftype )
then
vim . w . focus_disable = true
else
vim . w . focus_disable = false
end
end ,
desc = ' Disable focus autoresize for BufType ' ,
})
vim . api . nvim_create_autocmd ( ' FileType ' , {
group = augroup ,
callback = function ( _ )
if vim . tbl_contains ( ignore_filetypes , vim . bo . filetype ) then
vim . b . focus_disable = true
else
vim . b . focus_disable = false
end
end ,
desc = ' Disable focus autoresize for FileType ' ,
})아래 명령에 대한 자세한 내용은 아래로 스크롤하여 각각 설명하는 것을 자세히 볼 수 있습니다.
| 명령 | 설명 |
|---|---|
:FocusDisable | 세션 당 플러그인을 비활성화합니다. 스플릿은 기본값으로 다시 정규화 된 다음 골고루 간격으로됩니다. |
:FocusEnable | 세션 당 플러그인을 활성화합니다. 스플릿은 설정되지 않은 경우 구성 또는 기본값으로 다시 크기를 조정합니다. |
:FocusToggle | 초점 (전 세계적으로)을 다시 켜고 꺼집니다. |
:FocusSplitNicely | 황금 비율 규칙에 따라 창을 분할하십시오. |
:FocusSplitCycle | 스플릿이 없으면 하나를 만들고 이동하면 사이클에 중점을 둡니다. :FocusSplitCycle reverse |
:FocusDisableWindow | 현재 창 (WINNR)의 크기 조정을 비활성화합니다. |
:FocusEnableWindow | 현재 창 (WINNR)의 크기 조정을 활성화합니다. |
:FocusToggleWindow | 창마다 초점을 맞추고 꺼집니다. |
:FocusDisableBuffer | 전류 버퍼 (BUFNR)의 크기 조정을 비활성화합니다. |
:FocusEnableBuffer | 전류 버퍼 (BUFNR)의 크기 조정 활성화. |
:FocusToggleBuffer | 버퍼별로 다시 초점을 맞추고 꺼집니다. |
:FocusSplitLeft | 기존으로 이동하거나 현재 창의 왼쪽에 새 분할을 만듭니다. |
:FocusSplitDown | 기존으로 이동하거나 현재 창의 하단 + 열린 파일 또는 사용자 정의 명령으로 새 분할을 만듭니다. |
:FocusSplitUp | 기존으로 이동하거나 현재 창의 상단 + 열린 파일 또는 사용자 정의 명령으로 새 분할을 만듭니다. |
:FocusSplitRight | 기존으로 이동하거나 현재 창 + 열린 파일 또는 사용자 정의 명령의 오른쪽에 새 분할을 만듭니다. |
:FocusEqualise | 스플릿을 일시적으로 동일하게하여 모두 비슷한 너비/높이가됩니다. |
:FocusMaximise | 집중 창을 일시적으로 최대화합니다. |
:FocusMaxOrEqual | 스플릿을 평형화하거나 집중된 창을 극대화하는 것 사이의 토글. |
포커스를 사용하면 황금 비율에 따라 창문을 멋지게 타일 된 창으로 분할 할 수 있습니다.
+----------------+------------+
| | S1 |
| | |
| +------------+
| | |
| MAIN PANE | S2 |
| | |
| | |
| | |
+----------------+------------+
이보기를 얻으려면 키 조합을 2 번 누릅니다.
<Cl> 로 잘 분할하십시오 keymap ( ' n ' , ' <c-l> ' , function ()
require ( ' focus ' ). split_nicely ()
end , { desc = ' split nicely ' }) 또한 :FocusSplitNicely 명령으로 파일을 열거 나 사용자 정의 명령을 실행할 수 있습니다.
FocusSplitNicely 명령으로 생성 된 분할에서 파일을 엽니 다.
:FocusSplitNicely README.md
CMD arg를 사용하여 사용자 정의 명령을 실행하여 FocusSplitNicely 명령에 의해 생성 된 분할에서 터미널 창을 엽니 다.
:FocusSplitNicely cmd term
여러 명령과 바로 가기에 대해 걱정하는 대신, 어떤 방향으로 가고 싶은지 스플릿에 대해 생각하십시오 .
Focus Split 명령을 호출합니다. 즉, FocussPlitright는 두 가지 중 하나를 수행하면 지정된 방향으로 창으로 이동하려고 시도합니다 . 그렇지 않으면, 현재 창에 대한 지정된 방향에 창이 존재하지 않으면 대신 지정된 방향으로 새 빈 버퍼 창이 생성 된 다음 해당 창으로 이동합니다.
local focusmap = function ( direction )
vim . keymap . set ( ' n ' , ' <Leader> ' .. direction , function ()
require ( ' focus ' ). split_command ( direction )
end , { desc = string.format ( ' Create or move to split (%s) ' , direction ) })
end
-- Use `<Leader>h` to split the screen to the left, same as command FocusSplitLeft etc
focusmap ( ' h ' )
focusmap ( ' j ' )
focusmap ( ' k ' )
focusmap ( ' l ' ) 또한 :FocusSplit<direction> 명령으로 파일을 열거 나 사용자 정의 명령을 실행할 수 있습니다.
생성되거나 이동 한 분할로 파일을 엽니 다.
:FocusSplitRight README.md
CMD Arg를 사용하여 생성되거나 이동 한 분할에서 사용자 정의 명령을 실행하여 터미널 창을 열었습니다.
:FocusSplitDown cmd term
나는 작은 디스플레이가 있고 스플릿이 너무 많이 크기가 너무 크다는 것을 알게됩니다.
예를 들어 화면 해상도가 1024x768- > 즉 작은쪽에있는 경우 기본적으로 초점이 창을 너무 많이 최대화 할 수 있음을 알 수 있습니다.
즉, 창은 제한된 화면 부동산으로 인해 다른 분할 중 일부를 '크러쉬'할 것입니다. 이것은 초점과 관련된 문제가 아니라 최소 화면 부동산의 문제입니다. 이 경우 단순히 초점의 너비/높이를 줄일 수 있습니다.
QuickFix Window는 항상 오른쪽 분할에서 열립니다. 이것은 Focus.lua에 의한 것입니까?
아닙니다. 이것은 Core Vim의 문서화 된 설계 결정입니다. 이것은 상류로 조정할 수있는 것일 수 있습니다.
그 동안, 당신은 다음과 같이 창의 전체 너비를 차지하는 Quickfix 창을 열 수 있습니다 :botright copen
나는 다음과 같이 게으른로드 초점을 맞추려고 노력했지만, :FocusToggle 만 자동 레지즈 화를 위해 다시 전환해야합니다.
명령 :FocusToggle 있는 게으른 부하가 있으면 초점을로드하지만 처음에는 초점을 꺼냅니다. #34를 참조하십시오.
초점을로드 할 때 초점이 기본적으로 초점이 전환되기 때문에, :FocusToggle 한 다음 명령을 실행하면 다음과 같이 다시 전환합니다.
PR을 제출하기 전에 Stylua를 설치하고 focus.nvim 의 루트 폴더에서 실행하십시오.
stylua . 이것은 .stylua.toml 로 설정된 지침에 따라 코드를 형식화합니다.
GIT 하위 모듈을 초기화하는 경우 make test 사용하여 테스트를 실행할 수 있습니다.