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

@ -9,150 +9,163 @@ local cmd = vim.cmd
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
-- Global options
o.number = true -- show line number
o.showmatch = true -- show matching brackets
o.swapfile = false
g.hidden = true --unload buffers when hidden
g.filetype = true -- execute autocommands based on filetype
-- 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
cmd [[set mouse=a]] -- enable mouse interaction
cmd [[set undofile]]
cmd [[set fcs=eob:\ ]] --disable showing ~ in empty lines
cmd [[set undofile]]
cmd [[set fcs=eob:\ ]] --disable showing ~ in empty lines
cmd [[command Format :lua vim.lsp.buf.formatting()]]
cmd [[set noshowmode]] --to get rid of thing like --INSERT--
cmd [[set noshowcmd]] --to get rid of display of last command
cmd [[set shortmess+=F]] --to get rid of the file name displayed in the command line bar
cmd [[set noshowmode]] --to get rid of thing like --INSERT--
cmd [[set noshowcmd]] --to get rid of display of last command
cmd [[set shortmess+=F]] --to get rid of the file name displayed in the command line bar
cmd [[set noruler]]
g.ale_fixers = {"prettier", "eslint"}
-- Enable Theming / Syntax
o.syntax = "enable"
o.termguicolors = true
o.syntax = "enable"
o.termguicolors = true
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")
cmd("highlight NonText guibg=none")
-- Remove background color
require("transparent").setup({enable = true})
cmd("highlight Normal guibg=none")
cmd("highlight NonText guibg=none")
require('neoscroll').setup()
-- Configure nvim-tree
g.nvim_tree_special_files = {}
g.nvim_tree_icons = {
default = "",
symlink = "",
git = {
unstaged = "*",
staged = "",
unmerged = "",
renamed = "",
untracked = "",
deleted = "",
ignored = ""
},
folder = {
arrow_open = " ",
arrow_closed = " ",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = ""
},
lsp = {
hint = "",
info = "",
warning = "",
error = ""
}
}
g.nvim_tree_icons = {
default = "",
symlink = "",
git = {
unstaged = "*",
staged = "",
unmerged = "",
renamed = "",
untracked = "",
deleted = "",
ignored = ""
},
folder = {
arrow_open = " ",
arrow_closed = " ",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = ""
},
lsp = {
hint = "",
info = "",
warning = "",
error = ""
}
}
require("nvim-tree").setup {
auto_open = 1,
gitignore = 1,
group_empty = 1,
require("nvim-tree").setup {
auto_open = 1,
gitignore = 1,
group_empty = 1,
hijack_cursor = 1,
update_focused_file = {
enable = false,
},
diagnostics = {
diagnostics = {
enable = true
},
view = {
auto_resize = true,
hide_root_folder = true,
winopts = {
signcolumn = "no"
}
}
}
winopts = {
signcolumn = "no"
}
}
}
require('nvim-tree.view').View.winopts.signcolumn = 'no'
-- Configure Wiki
g.wiki_root = "~/Notes"
g.wiki_filetypes = {"md"}
g.wiki_link_extension = ".md"
g.wiki_root = "~/Notes"
g.wiki_filetypes = {"md"}
g.wiki_link_extension = ".md"
-- KeyBindings
g.mapleader = " "
require "keymappings"
-- KeyBindings
g.mapleader = " "
require "keymappings"
require "nvim-tmux-navigation".setup {
keybindings = {
left = "<C-h>",
down = "<C-j>",
up = "<C-k>",
right = "<C-l>",
last_active = "<C-\\>",
next = "<C-Space>"
}
}
require "nvim-tmux-navigation".setup {
keybindings = {
left = "<C-h>",
down = "<C-j>",
up = "<C-k>",
right = "<C-l>",
last_active = "<C-\\>",
next = "<C-Space>"
}
}
require'nvim-autopairs'.setup()
require'nvim-autopairs'.setup()
-- Treesitter config
require "treesitter-conf"
-- Treesitter config
require "treesitter-conf"
-- Toggleterm / Lazygit setup
require "lazy-git"
require "lazy-git"
-- Setup rest.vim
require("rest-nvim").setup(
{
-- Open request results in a horizontal split
result_split_horizontal = false,
-- Skip SSL verification, useful for unknown certificates
skip_ssl_verification = false,
-- Highlight request on run
highlight = {
enabled = true,
timeout = 150
},
-- Jump to request line on run
jump_to_request = false
}
)
-- Setup rest.vim
require("rest-nvim").setup(
{
-- Open request results in a horizontal split
result_split_horizontal = false,
-- Skip SSL verification, useful for unknown certificates
skip_ssl_verification = false,
-- Highlight request on run
highlight = {
enabled = true,
timeout = 150
},
-- Jump to request line on run
jump_to_request = false
}
)
-- Autocompletion Setup
o.completeopt = "menuone,noselect,noinsert"
require "autocomplete"
-- Autocompletion Setup
o.completeopt = "menuone,noselect,noinsert"
require "autocomplete"
-- LSP Config
require "lspinstaller-conf"
-- LSP Config
require "lspinstaller-conf"
require "lsp-utils"
else

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

@ -4,51 +4,51 @@ local utils = require("utils")
-- function to attach completion when setting up lsp
local function on_attach(client)
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...)
end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
local opts = {noremap = true, silent = true}
-- Mappings.
local opts = {noremap = true, silent = true}
-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
elseif client.resolved_capabilities.document_range_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
end
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
elseif client.resolved_capabilities.document_range_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
end
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec(
[[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
autocmd CursorHold *.* :lua vim.lsp.diagnostic.show_line_diagnostics()
augroup END
]],
false
)
end
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec(
[[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
autocmd CursorHold *.* :lua vim.lsp.diagnostic.show_line_diagnostics()
augroup END
]],
false
)
end
end
local system_name = ""
-- Lua Language Server
if vim.fn.has("mac") == 1 then
system_name = "macOS"
system_name = "macOS"
elseif vim.fn.has("unix") == 1 then
system_name = "Linux"
system_name = "Linux"
elseif vim.fn.has("win32") == 1 then
system_name = "Windows"
system_name = "Windows"
else
print("Unsupported system for sumneko")
print("Unsupported system for sumneko")
end
local sumneko_root_path = "/home/jim/.local/share/lua-language-server"
@ -59,164 +59,164 @@ table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
nvim_lsp.sumneko_lua.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
-- Setup your lua path
path = runtime_path
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {"vim"}
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true)
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false
}
}
}
on_attach = on_attach,
capabilities = lsp_status.capabilities,
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
-- Setup your lua path
path = runtime_path
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {"vim"}
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true)
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false
}
}
}
}
-- Go Language Server
nvim_lsp.gopls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- Html Setup
nvim_lsp.html.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
filetypes = {"html"}
on_attach = on_attach,
capabilities = lsp_status.capabilities,
filetypes = {"html"}
}
-- Svelte Language Server
nvim_lsp.svelte.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities
on_attach = on_attach,
capabilities = lsp_status.capabilities
}
-- Typescript Language Server
local function organize_imports()
local params = {
command = "_typescript.organizeImports",
arguments = {vim.api.nvim_buf_get_name(0)},
title = ""
}
vim.lsp.buf.execute_command(params)
local params = {
command = "_typescript.organizeImports",
arguments = {vim.api.nvim_buf_get_name(0)},
title = ""
}
vim.lsp.buf.execute_command(params)
end
nvim_lsp.tsserver.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
commands = {
OrganizeImports = {
organize_imports,
description = "Organize Imports"
}
}
on_attach = on_attach,
capabilities = lsp_status.capabilities,
commands = {
OrganizeImports = {
organize_imports,
description = "Organize Imports"
}
}
}
-- Setup diagnostics formaters and linters for non LSP provided files
nvim_lsp.diagnosticls.setup {
on_attach = on_attach,
capabilities = lsp_status.capabilities,
cmd = {"diagnostic-languageserver", "--stdio"},
filetypes = {
"lua",
"sh",
"markdown",
"json",
on_attach = on_attach,
capabilities = lsp_status.capabilities,
cmd = {"diagnostic-languageserver", "--stdio"},
filetypes = {
"lua",
"sh",
"markdown",
"json",
"jsonc",
"yaml",
"toml"
},
init_options = {
linters = {
shellcheck = {
command = "shellcheck",
debounce = 100,
args = {"--format", "json", "-"},
sourceName = "shellcheck",
parseJson = {
line = "line",
column = "column",
endLine = "endLine",
endColumn = "endColumn",
message = "${message} [${code}]",
security = "level"
},
securities = {
error = "error",
warning = "warning",
info = "info",
style = "hint"
}
},
markdownlint = {
command = "markdownlint",
isStderr = true,
debounce = 100,
args = {"--stdin"},
offsetLine = 0,
offsetColumn = 0,
sourceName = "markdownlint",
formatLines = 1,
formatPattern = {
"^.*?:\\s?(\\d+)(:(\\d+)?)?\\s(MD\\d{3}\\/[A-Za-z0-9-/]+)\\s(.*)$",
{
line = 1,
column = 3,
message = {4}
}
}
}
},
filetypes = {
sh = "shellcheck",
markdown = "markdownlint"
},
formatters = {
shfmt = {
command = "shfmt",
args = {"-i", "2", "-bn", "-ci", "-sr"}
},
prettier = {
command = "prettier",
args = {"--stdin-filepath", "%filepath"}
}
},
formatFiletypes = {
sh = "shfmt",
json = "prettier",
yaml = "prettier",
toml = "prettier",
markdown = "prettier",
lua = "prettier"
}
}
"yaml",
"toml"
},
init_options = {
linters = {
shellcheck = {
command = "shellcheck",
debounce = 100,
args = {"--format", "json", "-"},
sourceName = "shellcheck",
parseJson = {
line = "line",
column = "column",
endLine = "endLine",
endColumn = "endColumn",
message = "${message} [${code}]",
security = "level"
},
securities = {
error = "error",
warning = "warning",
info = "info",
style = "hint"
}
},
markdownlint = {
command = "markdownlint",
isStderr = true,
debounce = 100,
args = {"--stdin"},
offsetLine = 0,
offsetColumn = 0,
sourceName = "markdownlint",
formatLines = 1,
formatPattern = {
"^.*?:\\s?(\\d+)(:(\\d+)?)?\\s(MD\\d{3}\\/[A-Za-z0-9-/]+)\\s(.*)$",
{
line = 1,
column = 3,
message = {4}
}
}
}
},
filetypes = {
sh = "shellcheck",
markdown = "markdownlint"
},
formatters = {
shfmt = {
command = "shfmt",
args = {"-i", "2", "-bn", "-ci", "-sr"}
},
prettier = {
command = "prettier",
args = {"--stdin-filepath", "%filepath"}
}
},
formatFiletypes = {
sh = "shfmt",
json = "prettier",
yaml = "prettier",
toml = "prettier",
markdown = "prettier",
lua = "prettier"
}
}
}
-- Enable diagnostics
vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{
underline = true,
virtual_text = false,
signs = true,
update_in_insert = true
}
vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{
underline = true,
virtual_text = false,
signs = true,
update_in_insert = true
}
)

View File

@ -1,14 +1,14 @@
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.on_server_ready(function(server)
local opts = {}
local opts = {}
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
server:setup(opts)
vim.cmd [[ do User LspAttachBuffers ]]
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
server:setup(opts)
vim.cmd [[ do User LspAttachBuffers ]]
end)

View File

@ -1,68 +1,68 @@
local Terminal = require("toggleterm.terminal").Terminal
local u = require("utils")
local lazygit =
Terminal:new(
{
cmd = "lazygit",
dir = "git_dir",
direction = "float",
float_opts = {
winblend = 0,
border = "shadow"
},
on_open = function(term)
vim.cmd("startinsert!")
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", {noremap = true, silent = true})
end,
on_close = function(term)
Terminal:close()
end
}
Terminal:new(
{
cmd = "lazygit",
dir = "git_dir",
direction = "float",
float_opts = {
winblend = 0,
border = "shadow"
},
on_open = function(term)
vim.cmd("startinsert!")
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", {noremap = true, silent = true})
end,
on_close = function(term)
Terminal:close()
end
}
)
function _lazygit_toggle()
lazygit:toggle()
lazygit:toggle()
end
vim.api.nvim_set_keymap("n", "<C-g>", "<cmd>lua _lazygit_toggle()<CR>", {noremap = true, silent = true})
local pnpm =
Terminal:new(
{
cmd = "pnpm dev",
dir = "git_dir",
size = 5,
direction = "vertical",
on_close = function(term)
Terminal:close()
end
}
Terminal:new(
{
cmd = "pnpm dev",
dir = "git_dir",
size = 5,
direction = "vertical",
on_close = function(term)
Terminal:close()
end
}
)
function _pnpm_toggle()
pnpm:toggle()
pnpm:toggle()
end
vim.api.nvim_set_keymap("n", "<Leader>d", "<cmd>lua _pnpm_toggle()<CR>", {noremap = true, silent = true})
local nvimConfig =
Terminal:new(
{
cmd = "cd $HOME/.dotfiles && nvim configs/init.lua && cd -",
direction = "float",
on_close = function(term)
Terminal:close()
u.ReloadConfig()
end
}
Terminal:new(
{
cmd = "cd $HOME/.dotfiles && nvim configs/init.lua && cd -",
direction = "float",
on_close = function(term)
Terminal:close()
u.ReloadConfig()
end
}
)
function _nvimConfig_toggle()
nvimConfig:toggle()
nvimConfig:toggle()
end
vim.api.nvim_set_keymap("n", "<Leader><C-i>", "<cmd>lua _nvimConfig_toggle()<CR>", {noremap = true, silent = true})
require("toggleterm").setup {
shade_terminals = true
shade_terminals = true
}

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
@ -45,15 +45,16 @@ return require("packer").startup(function()
use "windwp/nvim-autopairs"
use "neoclide/jsonc.vim"
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
}
-- Preview Markdown
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

@ -1,26 +1,24 @@
local parser_configs = require("nvim-treesitter.parsers").get_parser_configs()
parser_configs.http = {
install_info = {
url = "https://github.com/NTBBloodbath/tree-sitter-http",
files = {"src/parser.c"},
branch = "main"
}
}
require "nvim-treesitter.configs".setup {
ensure_installed = {
"bash",
"yaml",
"http",
"svelte",
"css",
"svelte",
"typescript",
"javascript",
"go",
"lua",
"yaml"
},
highlight = {enable = true}
}
parser_configs.http = {
install_info = {
url = "https://github.com/NTBBloodbath/tree-sitter-http",
files = {"src/parser.c"},
branch = "main"
}
}
require "nvim-treesitter.configs".setup {
ensure_installed = {
"bash",
"yaml",
"http",
"svelte",
"css",
"svelte",
"typescript",
"javascript",
"go",
"lua",
"yaml"
},
highlight = {enable = true}
}

View File

@ -2,40 +2,40 @@ local M = {}
local cmd = vim.cmd
function M.create_augroup(autocmds, name)
cmd('augroup ' .. name)
cmd('autocmd!')
for _, autocmd in ipairs(autocmds) do
cmd('autocmd ' .. table.concat(autocmd, ' '))
end
cmd('augroup END')
cmd('augroup ' .. name)
cmd('autocmd!')
for _, autocmd in ipairs(autocmds) do
cmd('autocmd ' .. table.concat(autocmd, ' '))
end
cmd('augroup END')
end
function M.ReloadConfig()
for name,_ in pairs(package.loaded) do
if name:match('^cnull') then
package.loaded[name] = nil
end
end
for name,_ in pairs(package.loaded) do
if name:match('^cnull') then
package.loaded[name] = nil
end
end
dofile(vim.env.MYVIMRC)
dofile(vim.env.MYVIMRC)
end
local function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
function M.has_plugin(pluginName)
local status = pcall(require, pluginName);
return status
local status = pcall(require, pluginName);
return status
end
return M