Prettier for neovim and binds

laptop
E. Almqvist 1 year ago
parent e3bb86e043
commit fd5ca88b83
No known key found for this signature in database
GPG Key ID: E31A99CE3E75A158
  1. 5
      nvim/.config/nvim/lua/evim/packer.lua
  2. 0
      nvim/.config/nvim/plugin/after/comment.lua
  3. 1
      nvim/.config/nvim/plugin/after/lsp.lua
  4. 0
      nvim/.config/nvim/plugin/after/lualine.lua
  5. 34
      nvim/.config/nvim/plugin/after/null_ls.lua
  6. 0
      nvim/.config/nvim/plugin/after/presence.lua
  7. 19
      nvim/.config/nvim/plugin/after/prettier.lua
  8. 0
      nvim/.config/nvim/plugin/after/treesitter.lua
  9. 18
      nvim/.config/nvim/plugin/packer_compiled.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

@ -42,6 +42,7 @@ lsp.on_attach(function(client, bufnr)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
vim.keymap.set("n", "<A-g>", function()
vim.cmd "Prettier" -- NOTE: this is super hacky but fuck you
vim.lsp.buf.format { async = true }
end, opts)
end)

@ -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 = "<A-g>"
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,
})

@ -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",
},
})

@ -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

Loading…
Cancel
Save