Skip to content

Commit

Permalink
Merge pull request #15 from BitInByte/lua-config-v2
Browse files Browse the repository at this point in the history
Lua config v2
  • Loading branch information
BitInByte authored Jun 1, 2023
2 parents 9fecd9f + e21fb83 commit e111cfb
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 130 deletions.
11 changes: 10 additions & 1 deletion nvim/lua/core/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ keymap.set("n", "<space>e", vim.diagnostic.open_float, mappingOpts)
keymap.set("n", "[d", vim.diagnostic.goto_prev, mappingOpts)
keymap.set("n", "]d", vim.diagnostic.goto_next, mappingOpts)
keymap.set("n", "<space>q", vim.diagnostic.setloclist, mappingOpts)
-- keymap.set("n", "<space>q", '<cmd', mappingOpts)

-- vim.api.nvim_create_autocmd("LspAttach", {
-- group = vim.api.nvim_create_augroup("UserLspConfig", {}),
Expand Down Expand Up @@ -54,7 +55,13 @@ local on_attach = function(client, bufnr)
keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
keymap.set("n", "<space>bf", function()
vim.lsp.buf.format({ async = true })
-- vim.lsp.buf.format({ async = false })
vim.lsp.buf.format({
async = false,
filter = function(cli)
return cli.name == "null-ls"
end,
})
end, bufopts)
-- keymap.set("n", "<space>lA", vim.lsp.buf.format, bufopts)
end
Expand All @@ -78,6 +85,8 @@ local lsps_table = {
eslint_lsp = require(providers_path .. "eslint"),
angular_lsp = require(providers_path .. "angular"),
clang_lsp = require(providers_path .. "clang"),
php_lsp = require(providers_path .. "php"),
tailwind = require(providers_path .. "tailwind"),
}

-- LSP settings (for overriding per client)
Expand Down
91 changes: 50 additions & 41 deletions nvim/lua/core/null-ls/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,54 @@ local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics

null_ls.setup({
sources = {
formatting.stylua,
-- diagnostics.eslint_d,
-- diagnostics.eslint_d.with({
-- filetypes = { "javascript", "javascriptreact", "typescript", "vue", "html", "css" },
-- condition = function()
-- return utils.root_pattern(
-- "eslint.config.js",
-- -- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
-- ".eslintrc",
-- ".eslintrc.js",
-- ".eslintrc.cjs",
-- ".eslintrc.yaml",
-- ".eslintrc.yml",
-- ".eslintrc.json",
-- "package.json"
-- )(vim.api.nvim_buf_get_name(0)) ~= nil
-- -- )
-- end,
-- }),
formatting.prettierd,
formatting.phpcsfixer,
formatting.blade_formatter,
-- formatting.prettier,
-- require("typescript.extensions.null-ls.code-actions"),
},
-- you can reuse a shared lspconfig on_attach callback here
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
-- vim.lsp.buf.formatting_sync()
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
end,
sources = {
formatting.stylua,
-- diagnostics.eslint_d,
-- diagnostics.eslint_d.with({
-- filetypes = { "javascript", "javascriptreact", "typescript", "vue", "html", "css" },
-- condition = function()
-- return utils.root_pattern(
-- "eslint.config.js",
-- -- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
-- ".eslintrc",
-- ".eslintrc.js",
-- ".eslintrc.cjs",
-- ".eslintrc.yaml",
-- ".eslintrc.yml",
-- ".eslintrc.json",
-- "package.json"
-- )(vim.api.nvim_buf_get_name(0)) ~= nil
-- -- )
-- end,
-- }),
-- formatting.prettierd,
formatting.phpcsfixer,
formatting.blade_formatter,
formatting.prettier,
-- require("typescript.extensions.null-ls.code-actions"),
},
-- you can reuse a shared lspconfig on_attach callback here
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.notify("Formating with null ls")
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
-- vim.lsp.buf.formatting_sync()
-- vim.lsp.buf.format({ bufnr = bufnr })
vim.lsp.buf.format({
async = false,
filter = function(cli)
return cli.name == "null-ls"
end,
})
-- print("File formated with prettier")
end,
desc = "[lsp] format on save",
})
end
end,
})
18 changes: 10 additions & 8 deletions nvim/lua/modules/nv-git/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

return {

{
"lewis6991/gitsigns.nvim",
-- version = 'release' -- To use the latest release (do not use this if you build Neovim nightly or dev builds!)
config = function()
require("gitsigns").setup()
-- gitconflict.setup()
end,
},
{
"lewis6991/gitsigns.nvim",
-- version = 'release' -- To use the latest release (do not use this if you build Neovim nightly or dev builds!)
config = function()
require("gitsigns").setup({
current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame`
})
-- gitconflict.setup()
end,
},
}
136 changes: 71 additions & 65 deletions nvim/lua/modules/nv-lsp/init.lua
Original file line number Diff line number Diff line change
@@ -1,71 +1,77 @@
return {
{
"williamboman/mason.nvim",
dependencies = {
"williamboman/mason-lspconfig.nvim",
-- "jayp0521/mason-null-ls.nvim",
"jayp0521/mason-nvim-dap.nvim",
},
build = ":MasonUpdate", -- :MasonUpdate updates registry contents
config = function()
-- Everything related to LSP need to have the following order
-- Mason should be first and then lsp and lastly all of the others
-- If we change this order, can lead to unexpected behaviour
require("core.mason") -- lsp management
-- Lsp needs to be loaded after mason in order for
-- automatic_installation to work
require("core.lsp") -- lsp engine
require("core.cmp") -- completion
require("core.dap") -- debuggers management
require("core.null-ls") -- formaters management
end,
},

{
"neovim/nvim-lspconfig",
dependencies = {
{ "jose-elias-alvarez/typescript.nvim" },
{ "lervag/vimtex" },
{ "akinsho/flutter-tools.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
},
-- config = function()
-- -- require("core.lsp") -- lsp engine
-- end,
},
{
"neovim/nvim-lspconfig",
dependencies = {
{ "jose-elias-alvarez/typescript.nvim" },
{ "lervag/vimtex" },
{ "akinsho/flutter-tools.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
},
-- config = function()
-- -- require("core.lsp") -- lsp engine
-- end,
},

{
"williamboman/mason.nvim",
dependencies = {
"williamboman/mason-lspconfig.nvim",
-- "jayp0521/mason-null-ls.nvim",
"jayp0521/mason-nvim-dap.nvim",
},
build = ":MasonUpdate", -- :MasonUpdate updates registry contents
config = function()
require("core.mason") -- lsp management
-- Lsp needs to be loaded after mason in order for
-- automatic_installation to work
require("core.lsp") -- lsp engine
-- require("core.null-ls") -- formaters management
require("core.dap") -- debuggers management
end,
},
{
-- "jay-babu/mason-null-ls.nvim",
"jayp0521/mason-null-ls.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"williamboman/mason.nvim",
"jose-elias-alvarez/null-ls.nvim",
-- "jose-elias-alvarez/null-ls.nvim",
"nvim-lua/plenary.nvim",
},
-- config = function()
-- require("your.null-ls.config") -- require your null-ls config here (example below)
-- require("core.null-ls") -- formaters management
-- end,
},

{
-- "jay-babu/mason-null-ls.nvim",
"jayp0521/mason-null-ls.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"williamboman/mason.nvim",
"jose-elias-alvarez/null-ls.nvim",
-- "jose-elias-alvarez/null-ls.nvim",
"nvim-lua/plenary.nvim",
},
config = function()
-- require("your.null-ls.config") -- require your null-ls config here (example below)
require("core.null-ls") -- formaters management
end,
},
{
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
},
},

{ "mfussenegger/nvim-dap", dependencies = {
"rcarriga/nvim-dap-ui",
} },

-- LSP Sources && Modules
{
"hrsh7th/nvim-cmp",
config = function()
require("core.cmp") -- completion
end,
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp-signature-help",
"onsails/lspkind-nvim",
},
},
-- use({ "tzachar/cmp-tabnine", build = "./install.sh", dependencies = "hrsh7th/nvim-cmp" })
-- LSP Sources && Modules
{
"hrsh7th/nvim-cmp",
-- config = function()
-- require("core.cmp") -- completion
-- end,
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp-signature-help",
"onsails/lspkind-nvim",
},
},
-- use({ "tzachar/cmp-tabnine", build = "./install.sh", dependencies = "hrsh7th/nvim-cmp" })
}
7 changes: 6 additions & 1 deletion nvim/lua/modules/nv-lualine/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ return {
lualine_b = {
"filename",
{ "branch", icon = "" },
-- "diff",
{ "diagnostics", sources = { "nvim_diagnostic" } },
},
lualine_c = {},
Expand All @@ -67,7 +68,7 @@ return {
-- lualine_y = { { lspClients, icon = "ﴞ" }, "fileformat", "filetype", "progress" },
lualine_x = {},
-- lualine_y = { { lspClients, icon = "喇" }, "tabs", "filetype", "progress" },
lualine_y = { { lspClients, icon = "" }, "filetype", "progress" },
lualine_y = { { lspClients, icon = "" }, "filetype", "progress", "searchcount" },
lualine_z = {
{ "location", separator = { right = "" }, left_padding = 2 },
},
Expand Down Expand Up @@ -99,5 +100,9 @@ return {

vim.opt.laststatus = 3 -- Status bar always on bottom (shared)
end,
-- init = function()
-- vim.opt.laststatus = 3 -- Status bar always on bottom (shared)
-- vim.opt.termguicolors = true
-- end,
},
}
32 changes: 18 additions & 14 deletions nvim/lua/modules/nv-luasnip/init.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
return {
{
"L3MON4D3/LuaSnip",
dependencies = {

"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
},
config = function()
local luasnip = require("luasnip")
-- luasnip.filetype_extend("javascript", { "javascriptreact" })
luasnip.filetype_extend("typescript", { "typescriptreact" })
-- luasnip.filetype_extend("php", { "html" })
end,
},
{
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "<CurrentMajor>.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp",
dependencies = {
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
},
config = function()
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
-- luasnip.filetype_extend("javascript", { "javascriptreact" })
luasnip.filetype_extend("typescript", { "typescriptreact" })
luasnip.filetype_extend("php", { "html" })
end,
},
}
Loading

0 comments on commit e111cfb

Please sign in to comment.