diff --git a/.config/nvim/lua/lazyvim/plugins/lsp/format.lua b/.config/nvim/lua/lazyvim/plugins/lsp/format.lua index 2541beb..e68049a 100644 --- a/.config/nvim/lua/lazyvim/plugins/lsp/format.lua +++ b/.config/nvim/lua/lazyvim/plugins/lsp/format.lua @@ -1,6 +1,6 @@ local M = {} -M.autoformat = false +M.autoformat = true function M.toggle() M.autoformat = not M.autoformat @@ -8,19 +8,13 @@ function M.toggle() end function M.format() - local buf = vim.api.nvim_get_current_buf() - local ft = vim.bo[buf].filetype - local have_nls = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0 + local ok, conform = pcall(require, "conform") - vim.lsp.buf.format({ - bufnr = buf, - filter = function(client) - if have_nls then - return client.name == "null-ls" - end - return client.name ~= "null-ls" - end, - }) + if ok then + conform.format() + else + vim.lsp.buf.format() + end end function M.on_attach(client, buf) diff --git a/.config/nvim/lua/lazyvim/plugins/lsp/init.lua b/.config/nvim/lua/lazyvim/plugins/lsp/init.lua index 19222c0..7c2f52f 100644 --- a/.config/nvim/lua/lazyvim/plugins/lsp/init.lua +++ b/.config/nvim/lua/lazyvim/plugins/lsp/init.lua @@ -140,35 +140,47 @@ return { }, -- formatters + -- { + -- "jose-elias-alvarez/null-ls.nvim", + -- event = "BufReadPre", + -- dependencies = { "mason.nvim" }, + -- opts = function() + -- local nls = require("null-ls") + -- return { + -- root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"), + -- debug = false, + -- sources = { + -- nls.builtins.formatting.stylua, + -- nls.builtins.formatting.prettier.with({ + -- filetypes = { + -- "javascript", + -- "typescript", + -- "css", + -- "scss", + -- "html", + -- "json", + -- "yaml", + -- }, + -- }), + -- nls.builtins.formatting.black.with({ extra_args = { "--fast" } }), + -- nls.builtins.formatting.bibclean, + -- nls.builtins.formatting.beautysh, + -- nls.builtins.diagnostics.shellcheck, + -- }, + -- } + -- end, + -- }, { - "jose-elias-alvarez/null-ls.nvim", - event = "BufReadPre", - dependencies = { "mason.nvim" }, - opts = function() - local nls = require("null-ls") - return { - root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"), - debug = false, - sources = { - nls.builtins.formatting.stylua, - nls.builtins.formatting.prettier.with({ - filetypes = { - "javascript", - "typescript", - "css", - "scss", - "html", - "json", - "yaml", - }, - }), - nls.builtins.formatting.black.with({ extra_args = { "--fast" } }), - nls.builtins.formatting.bibclean, - nls.builtins.formatting.beautysh, - nls.builtins.diagnostics.shellcheck, - }, - } - end, + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + lua = { "stylua" }, + -- Conform will run multiple formatters sequentially + python = { "isort", "black" }, + -- Use a sub-list to run only the first available formatter + javascript = { { "prettierd", "prettier" } }, + }, + }, }, -- cmdline tools and lsp servers @@ -208,4 +220,5 @@ return { }, }, }, + require("lazyvim.plugins.lsp.lang.c_sharp"), } diff --git a/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua b/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua index 688980e..dfcef23 100644 --- a/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua +++ b/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua @@ -1,130 +1,130 @@ return { - { - "kyazdani42/nvim-tree.lua", - cmd = "NvimTreeToggle", - config = function() - local nvim_tree = require("nvim-tree") - local icons = require("lazyvim.config.icons") - - local function edit_or_open() - -- open as vsplit on current node - local action = "edit" - local node = lib.get_node_at_cursor() - - -- Just copy what's done normally with vsplit - if node.link_to and not node.nodes then - require("nvim-tree.actions.node.open-file").fn(action, node.link_to) - view.close() -- Close the tree if file was opened - elseif node.nodes ~= nil then - lib.expand_or_collapse(node) - else - require("nvim-tree.actions.node.open-file").fn(action, node.absolute_path) - view.close() -- Close the tree if file was opened - end - end - - nvim_tree.setup({ - hijack_directories = { - enable = false, - }, - ignore_ft_on_setup = { - "alpha", - }, - filters = { - custom = { ".git" }, - exclude = { ".gitignore" }, - }, - hijack_cursor = false, - update_cwd = true, - renderer = { - add_trailing = false, - group_empty = false, - highlight_git = false, - highlight_opened_files = "none", - root_folder_modifier = ":t", - indent_markers = { - enable = false, - icons = { - corner = "└ ", - edge = "│ ", - none = " ", - }, - }, - icons = { - webdev_colors = true, - git_placement = "before", - padding = " ", - symlink_arrow = " ➛ ", - show = { - file = true, - folder = true, - folder_arrow = true, - git = true, - }, - glyphs = { - default = "", - symlink = "", - folder = { - arrow_open = icons.ui.ArrowOpen, - arrow_closed = icons.ui.ArrowClosed, - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - }, - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - untracked = "U", - deleted = "", - ignored = "◌", - }, - }, - }, - }, - diagnostics = { - enable = true, - icons = { - hint = icons.diagnostics.Hint, - info = icons.diagnostics.Information, - warning = icons.diagnostics.Warning, - error = icons.diagnostics.Error, - }, - }, - update_focused_file = { - enable = true, - update_cwd = true, - ignore_list = {}, - }, - git = { - enable = true, - ignore = true, - timeout = 500, - }, - view = { - width = 30, - hide_root_folder = false, - side = "left", - number = false, - relativenumber = false, - mappings = { - custom_only = false, - list = { - { key = "l", action = "edit", action_cb = edit_or_open }, - { key = "h", action = "close_node" }, - }, - }, - }, - actions = { - open_file = { - quit_on_open = true, - }, - }, - }) - end, - }, + -- { + -- "kyazdani42/nvim-tree.lua", + -- cmd = "NvimTreeToggle", + -- config = function() + -- local nvim_tree = require("nvim-tree") + -- local icons = require("lazyvim.config.icons") + -- + -- local function edit_or_open() + -- -- open as vsplit on current node + -- local action = "edit" + -- local node = lib.get_node_at_cursor() + -- + -- -- Just copy what's done normally with vsplit + -- if node.link_to and not node.nodes then + -- require("nvim-tree.actions.node.open-file").fn(action, node.link_to) + -- view.close() -- Close the tree if file was opened + -- elseif node.nodes ~= nil then + -- lib.expand_or_collapse(node) + -- else + -- require("nvim-tree.actions.node.open-file").fn(action, node.absolute_path) + -- view.close() -- Close the tree if file was opened + -- end + -- end + -- + -- nvim_tree.setup({ + -- hijack_directories = { + -- enable = false, + -- }, + -- ignore_ft_on_setup = { + -- "alpha", + -- }, + -- filters = { + -- custom = { ".git" }, + -- exclude = { ".gitignore" }, + -- }, + -- hijack_cursor = false, + -- update_cwd = true, + -- renderer = { + -- add_trailing = false, + -- group_empty = false, + -- highlight_git = false, + -- highlight_opened_files = "none", + -- root_folder_modifier = ":t", + -- indent_markers = { + -- enable = false, + -- icons = { + -- corner = "└ ", + -- edge = "│ ", + -- none = " ", + -- }, + -- }, + -- icons = { + -- webdev_colors = true, + -- git_placement = "before", + -- padding = " ", + -- symlink_arrow = " ➛ ", + -- show = { + -- file = true, + -- folder = true, + -- folder_arrow = true, + -- git = true, + -- }, + -- glyphs = { + -- default = "", + -- symlink = "", + -- folder = { + -- arrow_open = icons.ui.ArrowOpen, + -- arrow_closed = icons.ui.ArrowClosed, + -- default = "", + -- open = "", + -- empty = "", + -- empty_open = "", + -- symlink = "", + -- symlink_open = "", + -- }, + -- git = { + -- unstaged = "", + -- staged = "S", + -- unmerged = "", + -- renamed = "➜", + -- untracked = "U", + -- deleted = "", + -- ignored = "◌", + -- }, + -- }, + -- }, + -- }, + -- diagnostics = { + -- enable = true, + -- icons = { + -- hint = icons.diagnostics.Hint, + -- info = icons.diagnostics.Information, + -- warning = icons.diagnostics.Warning, + -- error = icons.diagnostics.Error, + -- }, + -- }, + -- update_focused_file = { + -- enable = true, + -- update_cwd = true, + -- ignore_list = {}, + -- }, + -- git = { + -- enable = true, + -- ignore = true, + -- timeout = 500, + -- }, + -- view = { + -- width = 30, + -- hide_root_folder = false, + -- side = "left", + -- number = false, + -- relativenumber = false, + -- mappings = { + -- custom_only = false, + -- list = { + -- { key = "l", action = "edit", action_cb = edit_or_open }, + -- { key = "h", action = "close_node" }, + -- }, + -- }, + -- }, + -- actions = { + -- open_file = { + -- quit_on_open = true, + -- }, + -- }, + -- }) + -- end, + -- }, } diff --git a/.config/nvim/lua/lazyvim/plugins/snippets.lua b/.config/nvim/lua/lazyvim/plugins/snippets.lua index 6b63b4a..001364d 100644 --- a/.config/nvim/lua/lazyvim/plugins/snippets.lua +++ b/.config/nvim/lua/lazyvim/plugins/snippets.lua @@ -11,30 +11,11 @@ return { history = true, delete_check_events = "TextChanged", }, + -- stylua: ignore keys = { - { - "", - function() - return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" - end, - expr = true, - silent = true, - mode = "i", - }, - { - "", - function() - require("luasnip").jump(1) - end, - mode = "s", - }, - { - "", - function() - require("luasnip").jump(-1) - end, - mode = { "i", "s" }, - }, + { "", function() return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" end, expr = true, silent = true, mode = "i", }, + { "", function() require("luasnip").jump(1) end, mode = "s", }, + { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" }, }, }, }, }