Skip to content

Commit

Permalink
upgrade neovim lua
Browse files Browse the repository at this point in the history
  • Loading branch information
danwetherald committed May 24, 2022
1 parent 8db81c8 commit 239ce38
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**/plugged
nvim/undo/**.*
**/undo
nvim_old/plugged
nvim_old/undo
.DS_Store
Spoons
lang_servers
hammerspoon/Spoons
nvim_old/lang_servers
replacements.txt
nvim/plugin/packer_compiled.lua
43 changes: 43 additions & 0 deletions nvim/lua/custom/chadrc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local M = {}

-- Custom plugins
local override = require "custom.plugins.override"
local userPlugins = require "custom.plugins"

M.plugins = {

status = {
colorizer = true
},

options = {
lspconfig = {
setup_lspconf = "custom.plugins.lspconfig",
},

statusline = {
separator_style = "round",
},
},

override = {
["kyazdani42/nvim-tree.lua"] = override.nvimtree,
["nvim-treesitter/nvim-treesitter"] = override.treesitter,
},

user = userPlugins,

remove = {
"akinsho/bufferline.nvim"
}
}

-- Custom UI / Theme
M.ui = {
theme = "nightowl",
}

-- Custom mappings
M.mappings = require "custom.mappings"

return M
4 changes: 4 additions & 0 deletions nvim/lua/custom/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vim.api.nvim_create_autocmd('BufEnter', {
command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif",
nested = true,
})
17 changes: 17 additions & 0 deletions nvim/lua/custom/mappings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local M = {}

M.custom = {
n = {
["<leader>,"] = { "<cmd> w <CR>", "﬚ save file" },
["<leader>n"] = { "<cmd> NvimTreeToggle <CR>", " toggle nvimtree" },
["<space>"] = { "<cmd> set hlsearch! hlsearch? <CR>", "toggle highlighted search" },
["<leader>t"] = { "<cmd> Telescope find_files <CR>", " find files" },
["<leader>r"] = { "<cmd> Telescope live_grep <CR>", " live grep" },
},

i = {
["jj"] = { "<ESC>", "escape" },
}
}

return M
7 changes: 7 additions & 0 deletions nvim/lua/custom/plugins/dashboard-nvim.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local M = {}

M.setup = function()
vim.g.dashboard_default_executive = 'telescope'
end

return M
17 changes: 17 additions & 0 deletions nvim/lua/custom/plugins/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
return {
["nkrkv/nvim-treesitter-rescript"] = {},
["rescript-lang/vim-rescript"] = {ft = "rescript"},

["jose-elias-alvarez/null-ls.nvim"] = {
after = "nvim-lspconfig",
config = function()
require("custom.plugins.null-ls").setup()
end,
},

["glepnir/dashboard-nvim"] = {
config = function()
require("custom.plugins.dashboard-nvim").setup()
end,
}
}
16 changes: 16 additions & 0 deletions nvim/lua/custom/plugins/lspconfig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local M = {}

M.setup_lsp = function(attach, capabilities)
local lspconfig = require "lspconfig"

local servers = { "html", "cssls", "rescriptls", "solargraph", "tsserver" }

for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = attach,
capabilities = capabilities,
}
end
end

return M
34 changes: 34 additions & 0 deletions nvim/lua/custom/plugins/null-ls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local null_ls = require "null-ls"
local b = null_ls.builtins

local sources = {
-- Javascript
b.formatting.eslint,
b.formatting.rescript,
b.formatting.prettierd.with { filetypes = { "html", "markdown", "css", "javascript" } },
b.formatting.deno_fmt,

b.code_actions.eslint_d,
b.diagnostics.tsc,

-- Lua
b.formatting.stylua,
b.diagnostics.luacheck.with { extra_args = { "--global vim" } },
}

local M = {}

M.setup = function()
null_ls.setup {
debug = true,
sources = sources,
-- format on save
on_attach = function(client)
if client.resolved_capabilities.document_formatting then
vim.cmd "autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()"
end
end
}
end

return M
41 changes: 41 additions & 0 deletions nvim/lua/custom/plugins/override.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
local M = {}

M.treesitter = {
ensure_installed = {
"vim",
"html",
"css",
"javascript",
"json",
"toml",
"markdown",
"lua",
"ruby",
"tsx",
"prisma",
"graphql",
"dockerfile",
"rescript"
},
}

M.nvimtree = {
diagnostics = {
enable = true
},
git = {
enable = true
},
view = {
mappings = {
custom_only = false,
list = {
{ key = { "<CR>"}, action = "edit_no_picker" },
{ key = { "v"}, action = "vsplit" },
{ key = { "s"}, action = "split" },
}
}
}
}

return M

0 comments on commit 239ce38

Please sign in to comment.