-
Notifications
You must be signed in to change notification settings - Fork 0
/
polish.lua
executable file
·92 lines (83 loc) · 2.76 KB
/
polish.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
-- The function below will be executed last
return function()
-- disable comment continuation
vim.cmd [[set formatoptions-=cro]]
-- Set global key binding
-- local opts = { noremap = true, silent = true }
-- local keymap = vim.api.nvim_set_keymap
-- keymap("", "<S-h>", "^", opts)
-- keymap("", "<S-l>", "$", opts)
-- 自动切换输入法
vim.api.nvim_create_autocmd({ "InsertLeave" }, { pattern = "*", command = ":silent !fcitx5-remote -c" })
vim.api.nvim_create_autocmd({ "BufCreate" }, { pattern = "*", command = ":silent !fcitx5-remote -c" })
vim.api.nvim_create_autocmd({ "BufEnter" }, { pattern = "*", command = ":silent !fcitx5-remote -c" })
vim.api.nvim_create_autocmd({ "BufLeave" }, { pattern = "*", command = ":silent !fcitx5-remote -c" })
-- 打开时自动定位到上次关闭位置
vim.api.nvim_create_autocmd({ "BufReadPost" }, {
pattern = "*",
command = [[if line("'\"") >= 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]],
})
-- 使用.跳转到行首、行尾
vim.cmd [[
noremap <expr>. col(".")==1?"$":"0"
vnoremap <expr>. col(".")==1?"$h":"0"
]]
-- 显示空格
vim.cmd [[set list lcs=tab:\┊\ ,trail:▫]]
-- 加载markdown输入快捷方式
require "user.plugins.config.md1-snippets"
require "user.plugins.config.md2-snippets"
-- require "user.plugins.md3-snippets"
vim.api.nvim_create_autocmd(
{ "InsertLeave", "BufEnter", "BufNewFile" },
{ pattern = "*.md", command = "setlocal spell" }
)
-- heirline
-- require "user.heirline.colors"
-- require "user.heirline.separators"
-- require "user.heirline.heirline"
-- ruby环境变量
vim.g.ruby_host_prog = "~/.local/share/gem/ruby/3.0.0/bin/neovim-ruby-host"
-- 一键编译运行
-- 文件运行
vim.api.nvim_exec(
[[
func! CompileRunGccA()
exec "w"
for i in ["c","cpp","python","sh","html","go","lua","rust","r","nix","javascript","java","typescript"]
if &filetype == i
exec "RunFile float"
elseif &filetype == 'markdown'
exec "MarkdownPreview"
elseif &filetype == 'tex'
silent! exec "VimtexStop"
silent! exec "VimtexCompile"
" silent! exec "latexrun"
endif
endfor
endfunc
]],
false
)
-- 项目运行
vim.api.nvim_exec(
[[
func! CompileRunGccB()
exec "w"
for i in ["c","cpp","python","sh","html","go","lua","rust","r","nix","javascript","java","typescript"]
if &filetype == i
exec "RunProject"
elseif &filetype == 'markdown'
exec "MarkdownPreview"
elseif &filetype == 'tex'
silent! exec "VimtexStop"
silent! exec "VimtexCompile"
endif
endfor
endfunc
]],
false
)
-- run auto commands
require "user.autocmds"
end