feat: add autoformat

This commit is contained in:
max_richter 2021-11-17 12:54:51 +01:00
parent a39c4c6434
commit b32f64d2c4
9 changed files with 424 additions and 379 deletions

View File

@ -1,14 +1 @@
{
"0 debug pnpm:scope": {
"selected": 1
},
"1 error pnpm": {
"code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND",
"err": {
"name": "pnpm",
"message": "No package.json (or package.yaml, or package.json5) was found in \"/home/jim/.dotfiles\".",
"code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND",
"stack": "pnpm: No package.json (or package.yaml, or package.json5) was found in \"/home/jim/.dotfiles\".\n at readProjectManifest (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:40641:13)\n at async Object.readProjectManifestOnly (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:40645:28)\n at async Object.readProjectManifestOnly (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:40864:24)\n at async Object.handler (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:129763:24)\n at async /home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:133951:20\n at async run (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:133926:34)\n at async runPnpm (/home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:134137:5)\n at async /home/jim/.asdf/installs/nodejs/16.11.0/pnpm-global/5/node_modules/.pnpm/pnpm@6.17.2/node_modules/pnpm/dist/pnpm.cjs:134129:7"
}
}
}
{}

View File

@ -11,14 +11,27 @@ require ("plugins")
if u.has_plugin("cmp") then
-- Global options
o.number = true -- show line number
o.tabstop = 2
o.shiftwidth = 2 -- Indents will have a width of 4
o.softtabstop = 2 -- Sets the number of columns for a TAB
o.expandtab = false -- Dont expand TABs to spaces
o.autoindent = true
o.showmatch = true -- show matching brackets
o.swapfile = false
-- Indentation options
vim.cmd [[
set autoindent
set expandtab
set shiftwidth=2
set smartindent
set softtabstop=2
set tabstop=2
]]
-- Debug indentations
if false then
vim.cmd [[
set list
set listchars=eol:,tab:->,trail:_,nbsp:
]]
end
g.hidden = true --unload buffers when hidden
g.filetype = true -- execute autocommands based on filetype
@ -41,6 +54,7 @@ if u.has_plugin("cmp") then
cmd("colorscheme material")
g.material_terminal_italics = 1
g.material_theme_style = "darker"
-- Remove background color
require("transparent").setup({enable = true})
cmd("highlight Normal guibg=none")
@ -129,7 +143,6 @@ if u.has_plugin("cmp") then
-- Toggleterm / Lazygit setup
require "lazy-git"
-- Setup rest.vim
require("rest-nvim").setup(
{

View File

@ -0,0 +1,46 @@
require "format".setup {
["*"] = {
{cmd = {"sed -i 's/[ \t]*$//'"}} -- remove trailing whitespace
},
vim = {
{
cmd = {"luafmt -w replace"},
start_pattern = "^lua << EOF$",
end_pattern = "^EOF$"
}
},
vimwiki = {
{
cmd = {"prettier -w --parser babel"},
start_pattern = "^{{{javascript$",
end_pattern = "^}}}$"
}
},
lua = {
{
cmd = {
function(file)
return string.format("luafmt -l %s -w replace %s", vim.bo.textwidth, file)
end
}
}
},
go = {
{
cmd = {"gofmt -w", "goimports -w"},
tempfile_postfix = ".tmp"
}
},
javascript = {
{cmd = {"prettier -w", "./node_modules/.bin/eslint --fix"}}
},
markdown = {
{cmd = {"prettier -w"}},
{
cmd = {"black"},
start_pattern = "^```python$",
end_pattern = "^```$",
target = "current"
}
}
}

View File

@ -17,7 +17,7 @@ return require("packer").startup(function()
use "kyazdani42/nvim-tree.lua"
use "nvim-lua/popup.nvim"
use "mhinz/vim-startify"
use "lukas-reineke/indent-blankline.nvim"
--use "lukas-reineke/indent-blankline.nvim"
use "karb94/neoscroll.nvim"
-- Code Navigation
@ -53,7 +53,8 @@ return require("packer").startup(function()
use "ellisonleao/glow.nvim"
-- Autoformat
use "sbdchd/neoformat"
--use "sbdchd/neoformat"
use "lukas-reineke/format.nvim"
-- General Popup Window
use "akinsho/nvim-toggleterm.lua"

View File

@ -22,5 +22,3 @@ local parser_configs = require("nvim-treesitter.parsers").get_parser_configs()
},
highlight = {enable = true}
}