1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Compare commits

..

6 Commits

Author SHA1 Message Date
jdhao
64a7a23309
Merge pull request #64 from jdhao/fix-firenvim
update firenvim conf
2022-08-15 22:57:50 +08:00
jdhao
c1efc0bad6 update firenvim conf 2022-08-15 22:56:56 +08:00
jdhao
b3b69f21f4 update mapping 2022-08-15 00:22:24 +08:00
jdhao
f491e26676
Merge pull request #63 from jdhao/large-file
handle large file better
2022-08-15 00:08:16 +08:00
jdhao
e7e4892c22 handle large file better 2022-08-15 00:06:52 +08:00
jdhao
a52a362b02 update version check 2022-08-14 22:54:19 +08:00
5 changed files with 42 additions and 21 deletions

View File

@ -135,3 +135,23 @@ augroup auto_create_dir
autocmd!
autocmd BufWritePre * lua require('utils').may_create_dir()
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

View File

@ -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
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
endif

View File

@ -8,11 +8,14 @@
-- Email: jdhao@hotmail.com
-- Blog: https://jdhao.github.io/
local utils = require "utils"
local match_res = utils.check_version_match()
-- check if we have the latest stable version of nvim
local expected_ver = "0.7.2"
if not match_res.match then
local msg = string.format("Nvim version mistmatch: %s expected, but got %s instead!", match_res.expected, match_res.actual)
local utils = require "utils"
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, {})
return
end

View File

@ -1,8 +1,11 @@
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-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
keymap.set('i', '<C-D>', '<DEL>')

View File

@ -25,23 +25,11 @@ function M.may_create_dir()
end
end
function M.check_version_match()
-- check if we have the lastest stable version of nvim
local expected_ver = {major = 0, minor = 7, patch = 2}
function M.get_nvim_version()
local actual_ver = vim.version()
local ver_match = true
for key, val in pairs(expected_ver) do
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}
local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
return nvim_ver_str
end
return M