refactor(nvim): extract lua func
This commit is contained in:
parent
2388d030bd
commit
b0ff3024b3
18
nvimrc
18
nvimrc
|
@ -1,5 +1,6 @@
|
||||||
" Prefer $HOME/.vim to $HOME/.config/nvim (for now):
|
" Prefer $HOME/.vim to $HOME/.config/nvim (for now):
|
||||||
set runtimepath^=~/.vim runtimepath+=~/.vim/after
|
" TODO: refactor file structure for nvim
|
||||||
|
set runtimepath^=~/.vim runtimepath+=~/.vim/after runtimepath+=~/.vim/lua
|
||||||
let &packpath = &runtimepath
|
let &packpath = &runtimepath
|
||||||
|
|
||||||
set background=dark
|
set background=dark
|
||||||
|
@ -145,6 +146,9 @@ nnoremap <leader>dq ggVG"_d:wq<cr>
|
||||||
iabbrev esdebug debugger; // eslint-disable-line no-debugger
|
iabbrev esdebug debugger; // eslint-disable-line no-debugger
|
||||||
iabbrev bashstrict set -euo pipefail<cr>IFS=$'\n\t'<cr>
|
iabbrev bashstrict set -euo pipefail<cr>IFS=$'\n\t'<cr>
|
||||||
|
|
||||||
|
" lua includes
|
||||||
|
lua require("main")
|
||||||
|
|
||||||
lua <<EOF
|
lua <<EOF
|
||||||
function _G.dump(...)
|
function _G.dump(...)
|
||||||
local objects = vim.tbl_map(vim.inspect, {...})
|
local objects = vim.tbl_map(vim.inspect, {...})
|
||||||
|
@ -493,19 +497,9 @@ packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git
|
||||||
packadd! formatter.nvim " https://github.com/mhartington/formatter.nvim.git
|
packadd! formatter.nvim " https://github.com/mhartington/formatter.nvim.git
|
||||||
|
|
||||||
lua <<EOF
|
lua <<EOF
|
||||||
-- return prettier configuration. If a frontend/ path exists in project root,
|
|
||||||
-- assume node_modules will be found there.
|
|
||||||
local prettier = function()
|
local prettier = function()
|
||||||
local root_path = vim.fn.getcwd()
|
|
||||||
local frontend_path = root_path .. "/frontend"
|
|
||||||
local is_frontend = vim.fn.isdirectory(frontend_path) ~= 0
|
|
||||||
local base_path = root_path
|
|
||||||
if is_frontend then
|
|
||||||
base_path = frontend_path
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
exe = base_path .. "/node_modules/.bin/prettier",
|
exe = Get_project_node_modules_path() .. "/.bin/prettier",
|
||||||
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'},
|
args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'},
|
||||||
stdin = true
|
stdin = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
-- Return the node_modules path for this project. If the project root contains a
|
||||||
|
-- frontend/ directory, assume node_modules lives there.
|
||||||
|
function Get_project_node_modules_path()
|
||||||
|
local root_path = vim.fn.getcwd()
|
||||||
|
local frontend_path = root_path .. "/frontend"
|
||||||
|
local is_frontend = vim.fn.isdirectory(frontend_path) ~= 0
|
||||||
|
local base_path = root_path
|
||||||
|
if is_frontend then
|
||||||
|
base_path = frontend_path
|
||||||
|
end
|
||||||
|
return base_path .. "/node_modules"
|
||||||
|
end
|
|
@ -0,0 +1 @@
|
||||||
|
require "helpers"
|
Loading…
Reference in New Issue