more changes, maybe nicer now?

This commit is contained in:
Solomon Laing 2023-10-23 07:27:34 +10:30
parent 89ab8c246f
commit 496bdcc57f
4 changed files with 180 additions and 192 deletions

View File

@ -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"
if ok then
conform.format()
else
vim.lsp.buf.format()
end
return client.name ~= "null-ls"
end,
})
end
function M.on_attach(client, buf)

View File

@ -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",
"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" } },
},
}),
nls.builtins.formatting.black.with({ extra_args = { "--fast" } }),
nls.builtins.formatting.bibclean,
nls.builtins.formatting.beautysh,
nls.builtins.diagnostics.shellcheck,
},
}
end,
},
-- cmdline tools and lsp servers
@ -208,4 +220,5 @@ return {
},
},
},
require("lazyvim.plugins.lsp.lang.c_sharp"),
}

View File

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

View File

@ -11,30 +11,11 @@ return {
history = true,
delete_check_events = "TextChanged",
},
-- stylua: ignore
keys = {
{
"<tab>",
function()
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
end,
expr = true,
silent = true,
mode = "i",
},
{
"<tab>",
function()
require("luasnip").jump(1)
end,
mode = "s",
},
{
"<s-tab>",
function()
require("luasnip").jump(-1)
end,
mode = { "i", "s" },
},
{ "<tab>", function() return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>" end, expr = true, silent = true, mode = "i", },
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s", },
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" }, },
},
},
}