refactor(nvim): extract formatter.nvim config
This commit is contained in:
parent
124691d0d9
commit
39bb6188d8
30
nvimrc
30
nvimrc
|
@ -334,35 +334,7 @@ packadd! editorconfig-vim " https://github.com/editorconfig/editorconfig-vim.gi
|
||||||
packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git
|
packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git
|
||||||
|
|
||||||
" formatter.nvim
|
" formatter.nvim
|
||||||
packadd! formatter.nvim " https://github.com/mhartington/formatter.nvim.git
|
" See lua/formatter.lua
|
||||||
|
|
||||||
lua <<EOF
|
|
||||||
local prettier = function()
|
|
||||||
return {
|
|
||||||
exe = Get_project_node_modules_path() .. "/.bin/prettier",
|
|
||||||
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'},
|
|
||||||
stdin = true
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
require('formatter').setup({
|
|
||||||
filetype = {
|
|
||||||
javascript = { prettier },
|
|
||||||
typescript = { prettier },
|
|
||||||
typescriptreact = { prettier },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_exec([[
|
|
||||||
augroup FormatAutogroup
|
|
||||||
autocmd!
|
|
||||||
autocmd BufWritePost *.js,*.ts,*.tsx silent FormatWrite
|
|
||||||
augroup END
|
|
||||||
]], true)
|
|
||||||
|
|
||||||
local bufnr = vim.call("bufnr", "%")
|
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>F', '<Cmd>silent Format<CR>', { noremap=true, silent=true })
|
|
||||||
EOF
|
|
||||||
|
|
||||||
" enable inline vim highlighting:
|
" enable inline vim highlighting:
|
||||||
let g:vimsyn_embed= 'lPr'
|
let g:vimsyn_embed= 'lPr'
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
vim.api.nvim_command("packadd formatter.nvim")
|
||||||
|
|
||||||
|
local prettier = function()
|
||||||
|
return {
|
||||||
|
exe = Get_project_node_modules_path() .. "/.bin/prettier",
|
||||||
|
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'},
|
||||||
|
stdin = true
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
require('formatter').setup({
|
||||||
|
filetype = {
|
||||||
|
javascript = { prettier },
|
||||||
|
typescript = { prettier },
|
||||||
|
typescriptreact = { prettier },
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_exec2([[
|
||||||
|
augroup FormatAutogroup
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWritePost *.js,*.ts,*.tsx silent FormatWrite
|
||||||
|
augroup END
|
||||||
|
]], { output = true })
|
||||||
|
|
||||||
|
local bufnr = vim.fn.bufnr("%")
|
||||||
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>F', '<Cmd>silent Format<CR>', { noremap=true, silent=true })
|
|
@ -1,3 +1,4 @@
|
||||||
require "helpers"
|
require "helpers"
|
||||||
require "commands"
|
require "commands"
|
||||||
require "test_runner"
|
require "test_runner"
|
||||||
|
require "formatter_config"
|
||||||
|
|
Loading…
Reference in New Issue