1
Fork 0

feat: attempted to install prettierd

This commit is contained in:
Matei Adriel 2022-02-01 15:28:29 +02:00
parent 85cc99140c
commit 79455a6e29
12 changed files with 319 additions and 16577 deletions
dotfiles/neovim/lua/my/plugins

View file

@ -2,9 +2,19 @@ local mapSilent = require("my.keymaps").mapSilent
local M = {}
function M.setup()
local bindings = {
-- Open files with control + P
mapSilent('n', '<c-P>', "<cmd>lua require('fzf-lua').files()<CR>")
files = "<c-P>",
-- See diagnostics with space + d
lsp_document_diagnostics = "<space>d",
lsp_workspace_diagnostics = "<space>D"
}
function M.setup()
for action, keybind in pairs(bindings) do
-- Maps the keybind to the action
mapSilent('n', keybind, "<cmd>lua require('fzf-lua')." .. action .. "()<CR>")
end
end
return M
return M

View file

@ -84,16 +84,29 @@ function M.setup()
}
end
local efmLanguages = {
typescript = {
formatCommand = 'prettierd "${INPUT}"',
formatStdin = true,
env = {string.format('PRETTIERD_DEFAULT_CONFIG=%s', vim.fn.expand('~/.config/nvim/utils/linter-config/.prettierrc.json'))}
},
lua = {{formatCommand = formatLua, formatStdin = true}}
}
-- Setup auto-formatting
require"lspconfig".efm.setup {
init_options = {documentFormatting = true},
filetypes = {"lua"},
settings = {rootMarkers = {".git/"}, languages = {lua = {{formatCommand = formatLua, formatStdin = true}}}}
filetypes = {"lua", "ts", "js", "tsx", "jsx"},
settings = {rootMarkers = {".git/"}, languages = efmLanguages}
}
-- Auto format lua stuff
cmd("autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100)")
-- cmd("autocmd BufWritePre nix vim.lsp.buf.formatting_sync(nil, 100)")
local autoFormatOn = {lua = 100, purs = 1000, nix = 100, js = 100, ts = 100, tsx = 100, jsx = 100}
-- Auto format
for extension, timeout in pairs(autoFormatOn) do
-- I wonder if this could be done in a single glob pattern
cmd("autocmd BufWritePre *." .. extension .. " lua vim.lsp.buf.formatting_sync(nil, " .. timeout .. ")")
end
end
return M