Skip to content

Instantly share code, notes, and snippets.

@JeanOsorio
Last active August 2, 2022 18:28
Show Gist options
  • Save JeanOsorio/c678b04ae17e83de4dd2757df3fcfd6f to your computer and use it in GitHub Desktop.
Save JeanOsorio/c678b04ae17e83de4dd2757df3fcfd6f to your computer and use it in GitHub Desktop.
NVChad Custom Files
-- Just an example, supposed to be placed in /lua/custom/
local pluginConfs = require "custom.plugins.configs"
local M = {}
-- make sure you maintain the structure of `core/default_config.lua` here,
-- example of changing theme:
M.ui = {
theme = "catppuccin",
}
M.plugins = {
user = require "custom.plugins",
override = {
["kyazdani42/nvim-tree.lua"] = pluginConfs.nvimtree,
},
options = {
lspconfig = {
setup_lspconf = "custom.plugins.lspconfig",
},
},
}
return M
-- nvim/lua/custom/plugins/configs.lua
local M = {}
M.nvimtree = {
git = {
enable = true,
},
view = {
side = "right",
width = 20,
},
}
return M
-- nvim/lua/custom/plugins/init.lua
return {
["jose-elias-alvarez/null-ls.nvim"] = {
after = "nvim-lspconfig",
config = function()
require "custom.plugins.null-ls"
end,
}
}
-- nvim/lua/custom/plugins/lspconfig.lua
local M = {}
M.setup_lsp = function(attach, capabilities)
local lspconfig = require "lspconfig"
-- lspservers with default config
local servers = { "tsserver", "html", "cssls", "clangd", "cssmodules_ls", "emmet_ls", "solidity_ls" }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = attach,
capabilities = capabilities,
}
end
end
return M
local present, null_ls = pcall(require, "null-ls")
if not present then
return
end
local b = null_ls.builtins
local sources = {
-- webdev stuff
b.formatting.deno_fmt,
b.formatting.prettier,
-- Lua
b.formatting.stylua,
-- Shell
b.formatting.shfmt,
b.diagnostics.shellcheck.with { diagnostics_format = "#{m} [#{c}]" },
}
null_ls.setup {
debug = true,
sources = sources,
on_attach = function(client)
if client.resolved_capabilities.document_formatting then
vim.cmd "autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()"
end
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment