Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion v2/nvim/lua/johnmutuma/core/colorscheme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ keymap.set("n", "<leader>LL", ":colorscheme dayfox<CR>")
--
-- local success_colorscheme, _ = pcall(vim.cmd, "colorscheme tokyonight")
-- local success_colorscheme, _ = pcall(vim.cmd, "colorscheme ayu-dark")
local success_colorscheme, _ = pcall(vim.cmd, "colorscheme catppuccin-mocha")
-- local success_colorscheme, _ = pcall(vim.cmd, "colorscheme catppuccin-mocha")
-- local success_colorscheme, _ = pcall(vim.cmd, "colorscheme catppuccin-macchiato")
-- local success_colorscheme, _ = pcall(vim.cmd, "colorscheme nightfox")
local success_colorscheme, _ = pcall(vim.cmd, "colorscheme carbonfox")
--
-- NICE LIGHT THEMES
--
Expand Down
208 changes: 95 additions & 113 deletions v2/nvim/lua/johnmutuma/plugins/lsp/mason.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,32 @@ local mason_null_ls_ok, mason_null_ls = pcall(require, "mason-null-ls")
local cmp_nvim_lsp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
-- local typescript_ok, typescript = pcall(require, "typescript")

-- Configure Language servers LSP
local ensure_installed_lsp = {
"ts_ls",
"html",
"cssls",
"lua_ls",
"eslint",
"gopls",
-- "jsonls", -- preferring coc-json for workspace features
}

-- Configure Linters(Code Actions, Diagnostics) & Formatters bucket
local ensure_installed_null_ls = {
"prettier",
"stylua",
"eslint",
"cspell",
"gofumpt",
}
local workspaceSettings = require("johnmutuma.utils.workspace")

-- Sanity checks
if not cmp_nvim_lsp_ok then
print("cmp_nvim_lsp could not be loaded")
return
print("cmp_nvim_lsp could not be loaded")
return
end

if not mason_ok then
print("mason could not be loaded")
return
print("mason could not be loaded")
return
end

if not mason_lspconfig_ok then
print("mason-lspconfig could not be loaded")
return
print("mason-lspconfig could not be loaded")
return
end

if not lspconfig_ok then
print("lspconfig could not be loaded")
return
print("lspconfig could not be loaded")
return
end

if not mason_null_ls_ok then
print("mason_null_ls_ok could not be loaded")
return
print("mason_null_ls_ok could not be loaded")
return
end

-- if not typescript_ok then
Expand All @@ -62,87 +44,87 @@ mason.setup()

local capabilities = cmp_nvim_lsp.default_capabilities()
mason_lspconfig.setup({
ensure_installed = ensure_installed_lsp,
--
-- setup handlers for Mason installed lsp clients
handlers = {
-- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have a dedicated handler.
function(server_name) -- default handler (optional)
lspconfig[server_name].setup({
capabilities = capabilities,
-- on_attach = on_attach,
})
end,

["eslint"] = function()
lspconfig["eslint"].setup({
capabilities = capabilities,
-- on_attach = on_attach,
settings = {
options = {
-- Todo: "eslint options", this should be configured per project
resolvePluginsRelativeTo = "../eslint-config",
},
},
})
end,

["lua_ls"] = function()
lspconfig["lua_ls"].setup({
capabilities = capabilities,
-- on_attach = on_attach,

on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc") then
return
end
end

client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
-- library = vim.api.nvim_get_runtime_file("", true)
},
})
end,
settings = {
Lua = {},
},
})
end,

["gopls"] = function()
lspconfig["gopls"].setup({
capabilities = capabilities,
-- on_attach = on_attach,
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
gofumpt = true,
},
},
})
end,
},
ensure_installed = workspaceSettings.ensure_installed_lsp,
--
-- setup handlers for Mason installed lsp clients
handlers = {
-- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have a dedicated handler.
function(server_name) -- default handler (optional)
lspconfig[server_name].setup({
capabilities = capabilities,
-- on_attach = on_attach,
})
end,

["eslint"] = function()
lspconfig["eslint"].setup({
capabilities = capabilities,
-- on_attach = on_attach,
settings = {
options = workspaceSettings.eslintOptions,
workingDirectory = workspaceSettings.eslintWorkingDirectory,
codeActionOnSave = workspaceSettings.eslintCodeActionOnSave,
execArgv = workspaceSettings.eslintExecArgv,
},
})
end,

["lua_ls"] = function()
lspconfig["lua_ls"].setup({
capabilities = capabilities,
-- on_attach = on_attach,

on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc") then
return
end
end

client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
-- library = vim.api.nvim_get_runtime_file("", true)
},
})
end,
settings = {
Lua = {},
},
})
end,

["gopls"] = function()
lspconfig["gopls"].setup({
capabilities = capabilities,
-- on_attach = on_attach,
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
gofumpt = true,
},
},
})
end,
},
})

-- typescript.setup({
Expand All @@ -153,9 +135,9 @@ mason_lspconfig.setup({
-- })

mason_null_ls.setup({
ensure_installed = ensure_installed_null_ls,
automaticinstallation = false,
handlers = {},
ensure_installed = workspaceSettings.ensure_installed_null_ls,
automaticinstallation = false,
handlers = {},
})

-- Configure DAP bucket
Expand Down
34 changes: 34 additions & 0 deletions v2/nvim/lua/johnmutuma/utils/workspace.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local M = {}

-- LSP (Language server) clients to ensure are installed with Mason
M.ensure_installed_lsp = {
"ts_ls",
"html",
"cssls",
"lua_ls",
"eslint",
"gopls",
-- "jsonls", -- preferring coc-json for workspace features
}

-- Null-ls - Code formatters, linters, fixers, etc. installed with Mason
M.ensure_installed_null_ls = {
"prettier",
"stylua",
"eslint",
"cspell",
"gofumpt",
}

-- TODO - these should be read from a workspace config e.g. .vscode/settings.json
M.eslintExecArgv = { "--max_old_space_size=32568" }
M.eslintWorkingDirectory = { mode = "auto" }
M.eslintOptions = {
resolvePluginsRelativeTo = "../eslint-config",
}
M.eslintCodeActionOnSave = {
enable = true,
rules = { "!@typescript-eslint/*", "!import/order", "*" },
}

return M