require('lazy').setup({
-- NOTE: First, some plugins that don't require any configuration
+ 'jose-elias-alvarez/null-ls.nvim',
+ 'MunifTanjim/prettier.nvim',
+
+ '907th/vim-auto-save',
+
-- Git related plugins
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
- { 'j-hui/fidget.nvim', opts = {}, tag = 'legacy' },
+ { 'j-hui/fidget.nvim', opts = {}, tag = 'legacy' },
-- Additional lua configuration, makes nvim stuff amazing!
'folke/neodev.nvim',
{
-- Autocompletion
'hrsh7th/nvim-cmp',
- dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip',
- 'rafamadriz/friendly-snippets' },
+ dependencies = {
+ 'hrsh7th/cmp-nvim-lsp',
+ {'L3MON4D3/LuaSnip', version = "2.*", build = "make install_jsregexp"},
+ 'saadparwaiz1/cmp_luasnip',
+ 'rafamadriz/friendly-snippets'
+ },
},
-- Useful plugin to show you pending keybinds.
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- These are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them.
- require 'autoformat',
+ -- require 'autoformat',
-- require 'kickstart.plugins.debug',
-- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- Make line numbers default
vim.wo.relativenumber = true
+vim.wo.number = true
-- Enable mouse mode
vim.o.mouse = 'a'
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
+vim.keymap.set('n', '<S-F8>', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
+vim.keymap.set('n', '<F8>', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-
-- LSP settings.
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
},
}
+
+
+
+
+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"
+
+null_ls.setup({
+ on_attach = function(client, bufnr)
+ if client.supports_method("textDocument/formatting") then
+ vim.keymap.set("n", "<Leader>f", function()
+ vim.lsp.buf.format({ timeout = 10000, 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", "<Leader>f", function()
+ vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() })
+ end, { buffer = bufnr, desc = "[lsp] format" })
+ end
+ end,
+})
+
+
+local prettier = require("prettier")
+
+prettier.setup({
+ bin = 'prettierd', -- or `'prettierd'` (v0.23.3+)
+ filetypes = {
+ "css",
+ "graphql",
+ "html",
+ "javascript",
+ "javascriptreact",
+ "json",
+ "less",
+ "markdown",
+ "scss",
+ "typescript",
+ "typescriptreact",
+ "yaml",
+ },
+})
+
+vim.opt.diffopt = vim.opt.diffopt + "vertical"
+
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et