diff --git a/nvim/.config/nvim/lua/evim/packer.lua b/nvim/.config/nvim/lua/evim/packer.lua index b689c61..87450e3 100644 --- a/nvim/.config/nvim/lua/evim/packer.lua +++ b/nvim/.config/nvim/lua/evim/packer.lua @@ -31,6 +31,7 @@ return require("packer").startup(function(use) -- Themes use "savq/melange-nvim" use "chriskempson/base16-vim" + use "navarasu/onedark.nvim" -- LSP use { @@ -54,6 +55,8 @@ return require("packer").startup(function(use) { "L3MON4D3/LuaSnip" }, -- Required } } + use "jose-elias-alvarez/null-ls.nvim" + use "MunifTanjim/prettier.nvim" -- Misc -- use "vimsence/vimsence" @@ -75,8 +78,6 @@ return require("packer").startup(function(use) config = function() require("nvim-autopairs").setup {} end } - use "navarasu/onedark.nvim" - if packer_bootstrap then require("packer").sync() end diff --git a/nvim/.config/nvim/after/plugin/comment.lua b/nvim/.config/nvim/plugin/after/comment.lua similarity index 100% rename from nvim/.config/nvim/after/plugin/comment.lua rename to nvim/.config/nvim/plugin/after/comment.lua diff --git a/nvim/.config/nvim/after/plugin/lsp.lua b/nvim/.config/nvim/plugin/after/lsp.lua similarity index 96% rename from nvim/.config/nvim/after/plugin/lsp.lua rename to nvim/.config/nvim/plugin/after/lsp.lua index 235ac98..8220b61 100644 --- a/nvim/.config/nvim/after/plugin/lsp.lua +++ b/nvim/.config/nvim/plugin/after/lsp.lua @@ -42,6 +42,7 @@ lsp.on_attach(function(client, bufnr) vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) vim.keymap.set("n", "", function() + vim.cmd "Prettier" -- NOTE: this is super hacky but fuck you vim.lsp.buf.format { async = true } end, opts) end) diff --git a/nvim/.config/nvim/after/plugin/lualine.lua b/nvim/.config/nvim/plugin/after/lualine.lua similarity index 100% rename from nvim/.config/nvim/after/plugin/lualine.lua rename to nvim/.config/nvim/plugin/after/lualine.lua diff --git a/nvim/.config/nvim/plugin/after/null_ls.lua b/nvim/.config/nvim/plugin/after/null_ls.lua new file mode 100644 index 0000000..b5009b2 --- /dev/null +++ b/nvim/.config/nvim/plugin/after/null_ls.lua @@ -0,0 +1,34 @@ +local null_ls = require("null-ls") + +local group = vim.api.nvim_create_augroup("lsp_format_on_save", { clear = false }) +local event = "BufWritePre" -- or "BufWritePost" +local async = event == "BufWritePost" + +local format_bind = "" + +null_ls.setup({ + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.keymap.set("n", format_bind, function() + vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() }) + end, { buffer = bufnr, desc = "[lsp] Format" }) + + -- format on save + vim.api.nvim_clear_autocmds({ buffer = bufnr, group = group }) + vim.api.nvim_create_autocmd(event, { + buffer = bufnr, + group = group, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr, async = async }) + end, + desc = "[lsp] Format on save", + }) + end + + if client.supports_method("textDocument/rangeFormatting") then + vim.keymap.set("x", format_bind, function() + vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() }) + end, { buffer = bufnr, desc = "[lsp] Format" }) + end + end, +}) diff --git a/nvim/.config/nvim/after/plugin/presence.lua b/nvim/.config/nvim/plugin/after/presence.lua similarity index 100% rename from nvim/.config/nvim/after/plugin/presence.lua rename to nvim/.config/nvim/plugin/after/presence.lua diff --git a/nvim/.config/nvim/plugin/after/prettier.lua b/nvim/.config/nvim/plugin/after/prettier.lua new file mode 100644 index 0000000..58651bd --- /dev/null +++ b/nvim/.config/nvim/plugin/after/prettier.lua @@ -0,0 +1,19 @@ +local prettier = require("prettier") + +prettier.setup({ + bin = "prettier", -- or `"prettierd"` (v0.23.3+) + filetypes = { + "css", + "graphql", + "html", + "javascript", + "javascriptreact", + "json", + "less", + "markdown", + "scss", + "typescript", + "typescriptreact", + "yaml", + }, +}) diff --git a/nvim/.config/nvim/after/plugin/treesitter.lua b/nvim/.config/nvim/plugin/after/treesitter.lua similarity index 100% rename from nvim/.config/nvim/after/plugin/treesitter.lua rename to nvim/.config/nvim/plugin/after/treesitter.lua diff --git a/nvim/.config/nvim/plugin/packer_compiled.lua b/nvim/.config/nvim/plugin/packer_compiled.lua index 6b8ccb7..c14bb13 100644 --- a/nvim/.config/nvim/plugin/packer_compiled.lua +++ b/nvim/.config/nvim/plugin/packer_compiled.lua @@ -120,6 +120,11 @@ _G.packer_plugins = { path = "/home/elal/.local/share/nvim/site/pack/packer/start/melange-nvim", url = "https://github.com/savq/melange-nvim" }, + ["null-ls.nvim"] = { + loaded = true, + path = "/home/elal/.local/share/nvim/site/pack/packer/start/null-ls.nvim", + url = "https://github.com/jose-elias-alvarez/null-ls.nvim" + }, ["nvim-autopairs"] = { config = { "\27LJ\2\n@\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\19nvim-autopairs\frequire\0" }, loaded = true, @@ -167,6 +172,11 @@ _G.packer_plugins = { path = "/home/elal/.local/share/nvim/site/pack/packer/start/presence.nvim", url = "https://github.com/andweeb/presence.nvim" }, + ["prettier.nvim"] = { + loaded = true, + path = "/home/elal/.local/share/nvim/site/pack/packer/start/prettier.nvim", + url = "https://github.com/MunifTanjim/prettier.nvim" + }, ["telescope.nvim"] = { loaded = true, path = "/home/elal/.local/share/nvim/site/pack/packer/start/telescope.nvim", @@ -181,6 +191,10 @@ _G.packer_plugins = { } time([[Defining packer_plugins]], false) +-- Config for: Comment.nvim +time([[Config for Comment.nvim]], true) +try_loadstring("\27LJ\2\n5\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\fComment\frequire\0", "config", "Comment.nvim") +time([[Config for Comment.nvim]], false) -- Config for: nvim-autopairs time([[Config for nvim-autopairs]], true) try_loadstring("\27LJ\2\n@\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\19nvim-autopairs\frequire\0", "config", "nvim-autopairs") @@ -189,10 +203,6 @@ time([[Config for nvim-autopairs]], false) time([[Config for todo-comments.nvim]], true) try_loadstring("\27LJ\2\n?\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\18todo-comments\frequire\0", "config", "todo-comments.nvim") time([[Config for todo-comments.nvim]], false) --- Config for: Comment.nvim -time([[Config for Comment.nvim]], true) -try_loadstring("\27LJ\2\n5\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\fComment\frequire\0", "config", "Comment.nvim") -time([[Config for Comment.nvim]], false) _G._packer.inside_compile = false if _G._packer.needs_bufread == true then