Add Formatter Plugin
This commit is contained in:
parent
7e6edf6e73
commit
6d739e9ce5
|
@ -8,3 +8,21 @@ Created on: `date`
|
||||||
$0
|
$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
snippet def "Python Function" A
|
||||||
|
def ${1:function}($2):
|
||||||
|
"""
|
||||||
|
${3:function description}
|
||||||
|
|
||||||
|
Args:
|
||||||
|
${2} (${4:type}): ${5:description}
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
$6 ${7:description}
|
||||||
|
"""
|
||||||
|
`!p
|
||||||
|
if t[6] != "" and not t[8].endswith(f"return {t[6]}"):
|
||||||
|
t[8] = t[8] + f"\n\treturn {t[6]}"`
|
||||||
|
$8
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
|
122
init.lua
122
init.lua
|
@ -13,9 +13,8 @@ vim.opt.expandtab = true
|
||||||
vim.opt.showmatch = true
|
vim.opt.showmatch = true
|
||||||
vim.opt.cursorline = true
|
vim.opt.cursorline = true
|
||||||
vim.opt.hlsearch = true
|
vim.opt.hlsearch = true
|
||||||
vim.opt.encoding = 'UTF-8'
|
vim.opt.encoding = "UTF-8"
|
||||||
vim.g.tex_flavor = "latex"
|
vim.g.tex_flavor = "latex"
|
||||||
vim.g.clipboard = true
|
|
||||||
vim.opt.conceallevel = 2
|
vim.opt.conceallevel = 2
|
||||||
vim.opt.guifont = "DroidSansMono Nerd Font 11"
|
vim.opt.guifont = "DroidSansMono Nerd Font 11"
|
||||||
|
|
||||||
|
@ -26,17 +25,17 @@ colorscheme slate
|
||||||
]])
|
]])
|
||||||
|
|
||||||
-- vim.cmd('source ~/.config/nvim/viml/plugins.vim')
|
-- vim.cmd('source ~/.config/nvim/viml/plugins.vim')
|
||||||
require('plugins')
|
require("plugins")
|
||||||
|
|
||||||
-- UltiSnipsConfig
|
-- UltiSnipsConfig
|
||||||
vim.g.UltiSnipsExpandTrigger="<tab>"
|
vim.g.UltiSnipsExpandTrigger = "<tab>"
|
||||||
vim.g.UltiSnipsJumpForwardTrigger="<tab>"
|
vim.g.UltiSnipsJumpForwardTrigger = "<tab>"
|
||||||
vim.g.UltiSnipsJumpBackwardTrigger="<S-Tab>"
|
vim.g.UltiSnipsJumpBackwardTrigger = "<S-Tab>"
|
||||||
vim.g.UltiSnipsEditSplit="vertical"
|
vim.g.UltiSnipsEditSplit = "vertical"
|
||||||
vim.g.UltiSnipsSnippetDirectories={"~/.config/nvim/UltiSnips"}
|
vim.g.UltiSnipsSnippetDirectories = { "~/.config/nvim/UltiSnips" }
|
||||||
|
|
||||||
-- indentLine config
|
-- indentLine config
|
||||||
vim.g.indentLine_char = '▏'
|
vim.g.indentLine_char = "▏"
|
||||||
|
|
||||||
-- NERDTree Config
|
-- NERDTree Config
|
||||||
vim.g.NERDTreeShowHidden = 1
|
vim.g.NERDTreeShowHidden = 1
|
||||||
|
@ -45,6 +44,57 @@ vim.g.NERDTreeShowHidden = 1
|
||||||
vim.g.lexima_enable_basic_rules = 1
|
vim.g.lexima_enable_basic_rules = 1
|
||||||
vim.g.lexima_enable_newline_rules = 1
|
vim.g.lexima_enable_newline_rules = 1
|
||||||
|
|
||||||
|
-- Nvim Formatter
|
||||||
|
-- Utilities for creating configurations
|
||||||
|
local util = require("formatter.util")
|
||||||
|
|
||||||
|
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
|
||||||
|
require("formatter").setup({
|
||||||
|
-- Enable or disable logging
|
||||||
|
logging = true,
|
||||||
|
-- Set the log level
|
||||||
|
log_level = vim.log.levels.WARN,
|
||||||
|
-- All formatter configurations are opt-in
|
||||||
|
filetype = {
|
||||||
|
-- Formatter configurations for filetype "lua" go here
|
||||||
|
-- and will be executed in order
|
||||||
|
lua = {
|
||||||
|
-- "formatter.filetypes.lua" defines default configurations for the
|
||||||
|
-- "lua" filetype
|
||||||
|
require("formatter.filetypes.lua").stylua,
|
||||||
|
|
||||||
|
-- You can also define your own configuration
|
||||||
|
function()
|
||||||
|
-- Supports conditional formatting
|
||||||
|
if util.get_current_buffer_file_name() == "special.lua" then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Full specification of configurations is down below and in Vim help
|
||||||
|
-- files
|
||||||
|
return {
|
||||||
|
exe = "stylua",
|
||||||
|
args = {
|
||||||
|
"--search-parent-directories",
|
||||||
|
"--stdin-filepath",
|
||||||
|
util.escape_path(util.get_current_buffer_file_path()),
|
||||||
|
"--",
|
||||||
|
"-",
|
||||||
|
},
|
||||||
|
stdin = true,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Use the special "*" filetype for defining formatter configurations on
|
||||||
|
-- any filetype
|
||||||
|
["*"] = {
|
||||||
|
-- "formatter.filetypes.any" defines default configurations for any
|
||||||
|
-- filetype
|
||||||
|
require("formatter.filetypes.any").remove_trailing_whitespace,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
-- YCM config
|
-- YCM config
|
||||||
-- replace tab by crtl-k
|
-- replace tab by crtl-k
|
||||||
-- vim.cmd("let g:ycm_key_list_select_completion = ['<c-k>']")
|
-- vim.cmd("let g:ycm_key_list_select_completion = ['<c-k>']")
|
||||||
|
@ -52,24 +102,24 @@ vim.g.lexima_enable_newline_rules = 1
|
||||||
-- vim.g.ycm_global_ycm_extra_conf = '~/.config/nvim/python/.ycm_extra_conf.py'
|
-- vim.g.ycm_global_ycm_extra_conf = '~/.config/nvim/python/.ycm_extra_conf.py'
|
||||||
|
|
||||||
-- Treesitter config
|
-- Treesitter config
|
||||||
local configs = require'nvim-treesitter.configs'
|
local configs = require("nvim-treesitter.configs")
|
||||||
configs.setup {
|
configs.setup({
|
||||||
ensure_installed = {'python', 'c', 'cpp', 'lua', 'make', 'markdown'},
|
ensure_installed = { "python", "c", "cpp", "lua", "make", "markdown" },
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true;
|
enable = true,
|
||||||
},
|
},
|
||||||
indent = {
|
indent = {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
rainbow = {
|
rainbow = {
|
||||||
enable = true,
|
enable = true,
|
||||||
-- disable = {"langtodisable"},
|
-- disable = {"langtodisable"},
|
||||||
extended_mode = true,
|
extended_mode = true,
|
||||||
max_file_lines = 50000,
|
max_file_lines = 50000,
|
||||||
-- colors = {}, -- hex strings
|
-- colors = {}, -- hex strings
|
||||||
-- termcolors = {}, -- color names
|
-- termcolors = {}, -- color names
|
||||||
}
|
},
|
||||||
}
|
})
|
||||||
|
|
||||||
-- Let Treesitter fold with <zo> and <zc>, but keeps buffers unfolded on enter
|
-- Let Treesitter fold with <zo> and <zc>, but keeps buffers unfolded on enter
|
||||||
vim.opt.foldmethod = "expr"
|
vim.opt.foldmethod = "expr"
|
||||||
|
@ -78,34 +128,34 @@ vim.opt.foldenable = false
|
||||||
|
|
||||||
-- Mason setup
|
-- Mason setup
|
||||||
require("mason").setup(require("mason").setup({
|
require("mason").setup(require("mason").setup({
|
||||||
ui = {
|
ui = {
|
||||||
icons = {
|
icons = {
|
||||||
package_installed = "✓",
|
package_installed = "✓",
|
||||||
package_pending = "➜",
|
package_pending = "➜",
|
||||||
package_uninstalled = "✗"
|
package_uninstalled = "✗",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup({
|
||||||
ensure_installed = {"clangd", "cmake", "jdtls", "texlab", "pylsp"}
|
ensure_installed = { "clangd", "cmake", "jdtls", "texlab", "pylsp" },
|
||||||
})
|
})
|
||||||
|
|
||||||
require("mason-lspconfig").setup_handlers {
|
require("mason-lspconfig").setup_handlers({
|
||||||
function (clangd)
|
function(clangd)
|
||||||
require("lspconfig")[clangd].setup {}
|
require("lspconfig")[clangd].setup({})
|
||||||
end
|
end,
|
||||||
}
|
})
|
||||||
|
|
||||||
local wilder = require('wilder')
|
local wilder = require("wilder")
|
||||||
wilder.setup({modes = {':', '/', '?'}, next_key= '<Tab>', previous_key= '<S-Tab>', accept_key= '<c-k>', reject_key= '<Up>'})
|
wilder.setup({ modes = { ":", "/", "?" } }) --, next_key= '<Tab>', previous_key= '<S-Tab>', accept_key= '<c-k>', reject_key= '<Up>'})
|
||||||
|
|
||||||
require("code-completion")
|
require("code-completion")
|
||||||
|
|
||||||
-- neovide configuration
|
-- neovide configuration
|
||||||
if vim.g.neovide then
|
if vim.g.neovide then
|
||||||
vim.o.guifont = "DroidSansMono Nerd Font:8"
|
vim.o.guifont = "DroidSansMono Nerd Font:8"
|
||||||
vim.g.neovide_scale_factor = 1.0
|
vim.g.neovide_scale_factor = 1.0
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.cmd('source ~/.config/nvim/viml/legacyconf.vim')
|
vim.cmd("source ~/.config/nvim/viml/legacyconf.vim")
|
||||||
|
|
|
@ -3,7 +3,7 @@ let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-
|
||||||
let v:this_session=expand("<sfile>:p")
|
let v:this_session=expand("<sfile>:p")
|
||||||
silent only
|
silent only
|
||||||
silent tabonly
|
silent tabonly
|
||||||
cd ~/.config/nvim
|
cd ~
|
||||||
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
|
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
|
||||||
let s:wipebuf = bufnr('%')
|
let s:wipebuf = bufnr('%')
|
||||||
endif
|
endif
|
||||||
|
@ -13,26 +13,26 @@ if &shortmess =~ 'A'
|
||||||
else
|
else
|
||||||
set shortmess=aoO
|
set shortmess=aoO
|
||||||
endif
|
endif
|
||||||
badd +19 UltiSnips/all.snippets
|
badd +1 .config/nvim/init.lua
|
||||||
argglobal
|
argglobal
|
||||||
%argdel
|
%argdel
|
||||||
$argadd UltiSnips/all.snippets
|
$argadd .config/nvim/init.lua
|
||||||
edit UltiSnips/all.snippets
|
edit .config/nvim/init.lua
|
||||||
argglobal
|
argglobal
|
||||||
setlocal fdm=syntax
|
setlocal fdm=expr
|
||||||
setlocal fde=nvim_treesitter#foldexpr()
|
setlocal fde=nvim_treesitter#foldexpr()
|
||||||
setlocal fmr={{{,}}}
|
setlocal fmr={{{,}}}
|
||||||
setlocal fdi=#
|
setlocal fdi=#
|
||||||
setlocal fdl=99
|
setlocal fdl=0
|
||||||
setlocal fml=1
|
setlocal fml=1
|
||||||
setlocal fdn=20
|
setlocal fdn=20
|
||||||
setlocal nofen
|
setlocal nofen
|
||||||
let s:l = 19 - ((18 * winheight(0) + 25) / 50)
|
let s:l = 1 - ((0 * winheight(0) + 23) / 47)
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
keepjumps exe s:l
|
keepjumps exe s:l
|
||||||
normal! zt
|
normal! zt
|
||||||
keepjumps 19
|
keepjumps 1
|
||||||
normal! 056|
|
normal! 0
|
||||||
tabnext 1
|
tabnext 1
|
||||||
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
|
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
|
||||||
silent exe 'bwipe ' . s:wipebuf
|
silent exe 'bwipe ' . s:wipebuf
|
||||||
|
@ -46,6 +46,7 @@ if filereadable(s:sx)
|
||||||
endif
|
endif
|
||||||
let &g:so = s:so_save | let &g:siso = s:siso_save
|
let &g:so = s:so_save | let &g:siso = s:siso_save
|
||||||
set hlsearch
|
set hlsearch
|
||||||
|
nohlsearch
|
||||||
doautoall SessionLoadPost
|
doautoall SessionLoadPost
|
||||||
unlet SessionLoad
|
unlet SessionLoad
|
||||||
" vim: set ft=vim :
|
" vim: set ft=vim :
|
||||||
|
|
|
@ -42,4 +42,5 @@ return require('packer').startup(function(use)
|
||||||
use({"petertriho/cmp-git", requires = "nvim-lua/plenary.nvim"})
|
use({"petertriho/cmp-git", requires = "nvim-lua/plenary.nvim"})
|
||||||
use 'quangnguyen30192/cmp-nvim-ultisnips'
|
use 'quangnguyen30192/cmp-nvim-ultisnips'
|
||||||
use 'ryanoasis/vim-devicons'
|
use 'ryanoasis/vim-devicons'
|
||||||
|
use 'mhartington/formatter.nvim'
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -16,6 +16,12 @@ set splitbelow
|
||||||
|
|
||||||
set clipboard+=unnamedplus
|
set clipboard+=unnamedplus
|
||||||
|
|
||||||
|
" Autoformat on save
|
||||||
|
augroup FormatAutogroup
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePost * FormatWrite
|
||||||
|
augroup END
|
||||||
|
|
||||||
" Update Plugins and Treesitter languages
|
" Update Plugins and Treesitter languages
|
||||||
autocmd VimLeave * mksession! ~/.config/nvim/lastSession.vi
|
autocmd VimLeave * mksession! ~/.config/nvim/lastSession.vi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue