Skip to content

Commit

Permalink
🔥 Change vim template plugin
Browse files Browse the repository at this point in the history
Remove config of vim-template
Add smartinput config for jinja2
Fix bug of .Xsession
  • Loading branch information
Freed-Wu committed Mar 7, 2023
1 parent cbe86de commit 8682abb
Show file tree
Hide file tree
Showing 181 changed files with 968 additions and 829 deletions.
2 changes: 1 addition & 1 deletion .Xsession
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
# nixOS doesn't use it
[ command -v xinitrcsession-helper &>/dev/null ] && xinitrcsession-helper
[[ $(command -v xinitrcsession-helper) ]] &>/dev/null && xinitrcsession-helper
12 changes: 12 additions & 0 deletions .config/latexindent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env -S latexindent -l
---
defaultIndent: " "
indentPreamble: 1
fileExtensionPreference:
.dtx: 1
.ins: 2
.tex: 3
.sty: 4
.cls: 5
.tikz: 6
.bib: 7
1 change: 1 addition & 0 deletions .config/luacheck/.luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cache = true
1 change: 1 addition & 0 deletions .config/mimeapps.list
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ image/jpeg=lximage-qt.desktop;
image/png=lximage-qt.desktop;
image/gif=lximage-qt.desktop;
image/x-xpixmap=lximage-qt.desktop;
image/svg+xml=lximage-qt.desktop;
application/rtf=libreoffice-writer.desktop;
application/pdf=org.pwmt.zathura.desktop;
4 changes: 2 additions & 2 deletions .config/nvim/assets/json/menu/edit.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
["T&emplate", "Template"],
["&TemplateHere", "TemplateHere"],
["T&emplate", "1,1Template"],
["&TemplateHere", "Template"],
["--"],
["Trail &Fix", "TrailGuide fix"],
["--"],
Expand Down
2 changes: 1 addition & 1 deletion .config/nvim/autoload/init/firenvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ augroup init#firenvim
autocmd!
autocmd BufEnter www.bitahub.com_project-run_*.txt set filetype=sh
autocmd BufEnter forums.gentoo.org_*.txt set filetype=bbcode
autocmd BufEnter {{devforum,talk,discuss,discourse,gitlab}.*,*.stackexchange.com,aur.archlinux.org,github.com,www.{cnblogs,jianshu}.com}_*.txt set filetype=pandoc
autocmd BufEnter {{community,devforum,talk,discuss,discourse,gitlab}.*,*.stackexchange.com,aur.archlinux.org,github.com,www.{cnblogs,jianshu}.com}_*.txt set filetype=pandoc
autocmd BufEnter {bbs.archlinux.org,forums.gentoo.org}_*.txt set filetype=bbcode
autocmd BufEnter jqplay.org_jq_*.txt set filetype=jq
autocmd BufEnter colab.research.google.com_*.txt set filetype=python
Expand Down
103 changes: 0 additions & 103 deletions .config/nvim/autoload/init/init/template.vim

This file was deleted.

11 changes: 11 additions & 0 deletions .config/nvim/autoload/init/smartinput.vim
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ function! init#smartinput#post_source() abort
\ 'input': '%%' . left,
\ 'filetype': ['liquid', 'htmldjango', 'jinja2'],
\ })
call smartinput#define_rule({
\ 'at': '{\%#}',
\ 'char': '#',
\ 'input': '##' . left,
\ 'filetype': ['liquid', 'htmldjango', 'jinja2'],
\ })

call smartinput#map_to_trigger('i', '-*-', '-*-', '-*-')
call smartinput#define_rule({
Expand Down Expand Up @@ -208,6 +214,11 @@ function! init#smartinput#post_source() abort
\ 'char': '<Space>',
\ 'input': '<Space><Space>' . left,
\ })
call smartinput#define_rule({
\ 'at': '#\%##',
\ 'char': '<Space>',
\ 'input': '<Space><Space>' . left,
\ })
call smartinput#define_rule({
\ 'at': '%\%#%',
\ 'char': '-',
Expand Down
3 changes: 2 additions & 1 deletion .config/nvim/autoload/init/snippets.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function! init#snippets#source() abort
let g:snips_author = $DEBFULLNAME
let g:snips_email = $EMAIL
let g:snips_github = init#init#template#github()
let g:snips_github = 'https://github.com/Freed-Wu'
let g:snips_dockerhub_user = 'freedwu'
endfunction
24 changes: 0 additions & 24 deletions .config/nvim/autoload/init/template.vim

This file was deleted.

2 changes: 1 addition & 1 deletion .config/nvim/autoload/init/treesitter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function! init#treesitter#source() abort
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()
" lua/treesitter.lua
lua require("treesitter")
lua require"treesitter"
endfunction

function! s:init() abort
Expand Down
17 changes: 14 additions & 3 deletions .config/nvim/coc-settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"Lua.codeLens.enable": true,
"Lua.completion.callSnippet": "Both",
"Lua.hint.enable": true,
"Lua.hint.setType": true,
"cSpell.allowCompoundWords": true,
"clang-format-style-options.shortcut": "clang",
"coc.preferences.enableMarkdown": true,
Expand All @@ -12,7 +15,7 @@
"gitcommit": ["languagetool", "write-good", "alex-text"],
"html": "alex-html",
"jq": "jq",
"latex": "lacheck",
"lua": "luacheck",
"mail": ["languagetool", "write-good", "alex-text"],
"markdown": ["languagetool", "write-good", "alex"],
"nix": "nix-linter",
Expand All @@ -28,7 +31,6 @@
},
"diagnostic-languageserver.formatFiletypes": {
"blade": "blade-formatter",
"cmake": "cmake-format",
"dart": "dartfmt",
"elixir": "mix_format",
"fish": "fish_indent",
Expand All @@ -49,6 +51,16 @@
"highlight.document.enable": true,
"html.autoClosingTags": true,
"just-complete.shortcut": "_",
"languageserver": {
"cmake": {
"command": "cmake-language-server",
"filetypes": ["cmake"],
"rootPatterns": ["build/"],
"initializationOptions": {
"buildDirectory": "build"
}
}
},
"list.insertMappings": {
"<A-a>": "normal:gg",
"<A-e>": "normal:G",
Expand Down Expand Up @@ -86,7 +98,6 @@
"list.source.bibtex.files": ["*.bib", "refs/*.bib"],
"list.source.files.args": ["--hidden", "--files"],
"markdown-preview-enhanced.enableScriptExecution": true,
"perl.disableCache": true,
"prettier.ignorePath": ".gitignore",
"pydocstring.doqPath": "/usr/bin/doq",
"pydocstring.enableFileAction": true,
Expand Down
38 changes: 0 additions & 38 deletions .config/nvim/doc/my-init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,6 @@ INTRODUCTION *my-init-intro*
==============================================================================
FUNCTIONS *my-init-functions*

init#init#template#dir() *init#init#template#dir()*
for LaTeX package script foo/build.lua -> foo for pre-commit hook config
foo/.pre-commit_hooks.yaml -> foo for README.md foo/README.md -> foo

init#init#template#dir_() *init#init#template#dir_()*
for pyproject.toml foo-bar/pyproject.toml -> foo_bar

init#init#template#dir2() *init#init#template#dir2()*
for sphinx config file: foo/docs/conf.py -> foo

init#init#template#dir2_() *init#init#template#dir2_()*
for pytest file: foo-bar/tests/baz_test.py -> foo_bar

init#init#template#dir3() *init#init#template#dir3()*
for github actions: foo/.github/workflows/main.yml -> foo

init#init#template#perldir() *init#init#template#perldir()*
for perl: Foo-Bar -> Foo::Bar

init#init#template#perlfile() *init#init#template#perlfile()*
for perl: Foo-Bar -> Foo/Bar

init#init#template#perllib() *init#init#template#perllib()*
for perl lib: lib/Foo/Bar.pm -> FooBar

init#init#template#cfile() *init#init#template#cfile()*
for homebrew package script: foo-bar -> FooBar foo-bar.rb -> class FooBar <
Formula

init#init#template#file_() *init#init#template#file_()*
for zsh completion script: _foo -> foo

init#init#template#test_file() *init#init#template#test_file()*
for pytest python script: foo_test.py -> foo

init#init#template#ext() *init#init#template#ext()*
for neomutt config: neomutt.foo -> foo

init#init#vim#map() *init#init#vim#map()*
assets/json/context/normal/vim.json

Expand Down
5 changes: 5 additions & 0 deletions .config/nvim/ftplugin/jinja2.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
for s:dir in g:template#directories
if expand('%:p:h') ==# s:dir
call init#init#vim#map()
endif
endfor
3 changes: 3 additions & 0 deletions .config/nvim/ftplugin/tex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ setlocal iskeyword-=:
setlocal spell

let b:browser_search_default_engine = 'ctan'
if expand('%:e') ==# 'dtx'
let b:match_words = '%<\*driver>:%<\/driver>,%<\*cls>:%<\/cls>,%<\*sty>:%<\/sty>,%<\*cls|sty>:%<\/cls|sty>'
endif

call init#init#tex#main()
6 changes: 1 addition & 5 deletions .config/nvim/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,7 @@ if dein#load_state(expand('$XDG_DATA_HOME/nvim'))
call dein#add('honza/vim-snippets', {
\ 'hook_source': 'call init#snippets#source()',
\ })
" if BufNewFile, augroup Templates will be loaded in next BufNewFile
call dein#add('aperezdc/vim-template', {
\ 'hook_source': 'call init#template#source()',
\ })
" call dein#add('Freed-Wu/template.vim')
call dein#add('Freed-Wu/template.vim')
call dein#add('mattn/emmet-vim', {
\ 'on_map': {'n': '<C-y>', 'v': '<C-y>', 'i': '<C-y>'},
\ })
Expand Down
5 changes: 5 additions & 0 deletions .config/nvim/lua/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---treesitter config.
-- don't install automatically to avoid network failure
require"nvim-treesitter.configs".setup {
indent = {enable = true},
Expand All @@ -17,11 +18,15 @@ ft_to_parser.pandoc = "markdown"
ft_to_parser.mysql = "sql"
ft_to_parser.eelixir = "elixir"
ft_to_parser.sublime_syntax = "yaml"
-- luacheck: globals vim
---@diagnostic disable-next-line: undefined-global
vim.api.nvim_create_autocmd("FileType", {
pattern = "liquid",
callback = function(args)
---@diagnostic disable-next-line: undefined-global
vim.treesitter.start(args.buf, vim.b.liquid_subtype)
-- only if additional legacy syntax is needed
---@diagnostic disable-next-line: undefined-global
vim.bo[args.buf].syntax = "on"
end
})
9 changes: 0 additions & 9 deletions .config/nvim/template/.desktop

This file was deleted.

Loading

0 comments on commit 8682abb

Please sign in to comment.