mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
6 Commits
2880d7bce3
...
64a7a23309
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64a7a23309 | ||
|
|
c1efc0bad6 | ||
|
|
b3b69f21f4 | ||
|
|
f491e26676 | ||
|
|
e7e4892c22 | ||
|
|
a52a362b02 |
@ -135,3 +135,23 @@ augroup auto_create_dir
|
|||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufWritePre * lua require('utils').may_create_dir()
|
autocmd BufWritePre * lua require('utils').may_create_dir()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
" ref: https://vi.stackexchange.com/a/169/15292
|
||||||
|
function! s:handle_large_file() abort
|
||||||
|
let g:large_file = 10485760 " 10MB
|
||||||
|
let f = expand("<afile>")
|
||||||
|
|
||||||
|
if getfsize(f) > g:large_file || getfsize(f) == -2
|
||||||
|
set eventignore+=all
|
||||||
|
" turning off relative number helps a lot
|
||||||
|
set norelativenumber
|
||||||
|
setlocal noswapfile bufhidden=unload buftype=nowrite undolevels=-1
|
||||||
|
else
|
||||||
|
set eventignore-=all relativenumber
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
augroup LargeFile
|
||||||
|
autocmd!
|
||||||
|
autocmd BufReadPre * call s:handle_large_file()
|
||||||
|
augroup END
|
||||||
|
|||||||
@ -371,9 +371,16 @@ if exists('g:started_by_firenvim') && g:started_by_firenvim
|
|||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
function! s:setup_firenvim() abort
|
||||||
|
set noruler noshowcmd
|
||||||
|
set laststatus=0 showtabline=0
|
||||||
|
endfunction
|
||||||
|
|
||||||
augroup firenvim
|
augroup firenvim
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufEnter *.txt setlocal filetype=markdown laststatus=0 nonumber noshowcmd noruler showtabline=1
|
autocmd FileType text call s:setup_firenvim()
|
||||||
|
autocmd BufNewFile github.com_*.txt set filetype=markdown
|
||||||
|
autocmd BufNewFile stackoverflow.com_*.txt set filetype=markdown
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
11
init.lua
11
init.lua
@ -8,11 +8,14 @@
|
|||||||
-- Email: jdhao@hotmail.com
|
-- Email: jdhao@hotmail.com
|
||||||
-- Blog: https://jdhao.github.io/
|
-- Blog: https://jdhao.github.io/
|
||||||
|
|
||||||
local utils = require "utils"
|
-- check if we have the latest stable version of nvim
|
||||||
local match_res = utils.check_version_match()
|
local expected_ver = "0.7.2"
|
||||||
|
|
||||||
if not match_res.match then
|
local utils = require "utils"
|
||||||
local msg = string.format("Nvim version mistmatch: %s expected, but got %s instead!", match_res.expected, match_res.actual)
|
local nvim_ver = utils.get_nvim_version()
|
||||||
|
|
||||||
|
if nvim_ver ~= expected_ver then
|
||||||
|
local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver)
|
||||||
vim.api.nvim_echo({ { msg, "ErrorMsg" } }, false, {})
|
vim.api.nvim_echo({ { msg, "ErrorMsg" } }, false, {})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
|
|
||||||
-- Go to the begining and end of current line in insert mode quickly
|
-- Go to the beginning and end of current line in insert mode quickly
|
||||||
keymap.set('i', '<C-A>', '<HOME>')
|
keymap.set('i', '<C-A>', '<HOME>')
|
||||||
keymap.set('i', '<C-E>', '<END>')
|
keymap.set('i', '<C-E>', '<END>')
|
||||||
|
|
||||||
|
-- Go to beginning of command in command-line mode
|
||||||
|
keymap.set('c', '<C-A>', '<HOME>')
|
||||||
|
|
||||||
-- Delete the character to the right of the cursor
|
-- Delete the character to the right of the cursor
|
||||||
keymap.set('i', '<C-D>', '<DEL>')
|
keymap.set('i', '<C-D>', '<DEL>')
|
||||||
|
|||||||
@ -25,23 +25,11 @@ function M.may_create_dir()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.check_version_match()
|
function M.get_nvim_version()
|
||||||
-- check if we have the lastest stable version of nvim
|
|
||||||
local expected_ver = {major = 0, minor = 7, patch = 2}
|
|
||||||
local actual_ver = vim.version()
|
local actual_ver = vim.version()
|
||||||
|
|
||||||
local ver_match = true
|
local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
||||||
for key, val in pairs(expected_ver) do
|
return nvim_ver_str
|
||||||
if val ~= actual_ver[key] then
|
|
||||||
ver_match = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local expect_ver_str = string.format("%s.%s.%s", expected_ver.major, expected_ver.minor, expected_ver.patch)
|
|
||||||
local nvim_ver_str = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
|
||||||
|
|
||||||
return {match=ver_match, expected=expect_ver_str, actual=nvim_ver_str}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user