Compare commits

...

2 Commits

7 changed files with 135 additions and 7 deletions

View File

@ -3,14 +3,48 @@ return {
config = function()
local conform = require("conform")
local function file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
local function decide_js_formatter()
local cwd = vim.fn.getcwd()
if file_exists(cwd .. "/biome.json") then
return "biome"
else
return "prettier"
end
end
local function decide_json_formatter()
local cwd = vim.fn.getcwd()
if file_exists(cwd .. "/biome.json") then
return "biome"
elseif file_exists(cwd .. "/.prettierrc") then
return "prettier"
else
return "jq"
end
end
conform.setup({
formatters_by_ft = {
javascript = { decide_js_formatter() },
javascriptreact = { decide_js_formatter() },
json = { decide_json_formatter() },
lua = { "stylua" },
markdown = { "mdformat" },
nginx = { "nginxfmt" },
python = { "black", "flake8" },
python = { "isort", "black" },
sh = { "shfmt" },
typescript = { decide_js_formatter() },
typescriptreact = { decide_js_formatter() },
yaml = { "yamlfix" },
-- Use the "*" filetype to run formatters on all filetypes.
-- ["*"] = { "codespell" },
["*"] = { "codespell" },
},
default_format_opts = {

View File

@ -0,0 +1,48 @@
return {
"mfussenegger/nvim-lint",
config = function()
local function file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
local function decide_linter()
local cwd = vim.fn.getcwd()
if file_exists(cwd .. "/biome.json") then
return "biome"
else
return "eslint_d"
end
end
local lint = require("lint")
lint.linters_by_ft = {
javascript = { "eslint_d" },
javascriptreact = { "eslint_d" },
markdown = { "markdownlint" },
python = { "flake8" },
sh = { "shellcheck" },
typescript = { "eslint_d" },
typescriptreact = { "eslint_d" },
yaml = { "yamllint" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>l", function()
lint.try_lint()
end, { desc = "Trigger linting for current file" })
end,
}

View File

@ -18,9 +18,11 @@ return {
require("mason-lspconfig").setup({
ensure_installed = {
"bashls",
"cssls",
"dockerls",
"emmet_ls",
"eslint",
"html",
"jdtls",
"jsonls",
@ -43,10 +45,15 @@ return {
"eslint_d",
"firefox-debug-adapter",
"flake8",
"isort",
"java-debug-adapter",
"jq",
"markdownlint",
"mdformat",
"nginx-config-formatter",
"prettierd",
"prettier",
"shellcheck",
"shfmt",
"stylua",
"yamlfix",
"yamllint",

View File

@ -134,6 +134,17 @@ return {
root_markers = { "tsconfig.json", "jsconfig.json", "package.json" },
})
vim.lsp.config("jsonls", {
on_attach = function(client)
-- Disable formatting capability for tsserver
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
filetypes = {
"json",
},
})
vim.lsp.config("pylsp", {
on_attach = function(client)
client.server_capabilities.documentFormattingProvider = false
@ -144,5 +155,15 @@ return {
},
root_markers = { "requirements.txt" },
})
vim.lsp.config("bashls", {
on_attach = function(client)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
filetypes = {
"sh",
},
})
end,
}

5
.gitignore vendored
View File

@ -6,12 +6,10 @@
!.config/neofetch/*
!.config/nvim/init.lua
!.config/nvim/lua/**
!.config/nvim/*
!.config/tmux/tmux.conf
!.config/tmux/catppuccin.conf
.config/tmux/local.tmux.config
!.config/waybar/*
@ -20,3 +18,4 @@
!.zinit.zsh
!.zshrc
!.zstyle.zsh
!.wslrc.zsh

15
.wslrc.zsh Normal file
View File

@ -0,0 +1,15 @@
# Fix HOME, END, and DEL keys for zsh
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[3~" delete-char
# Fix HOME and END for tmux
bindkey "\E[1~" beginning-of-line
bindkey "\E[4~" end-of-line
# Set vals for C-Right, C-S-Right, C-Left, C-S-Left
# To move through words
bindkey "^[[1;6D" vi-backward-word
bindkey "^[[1;5D" backward-word
bindkey "^[[1;6C" vi-forward-word
bindkey "^[[1;5C" emacs-forward-word

4
.zshrc
View File

@ -49,4 +49,8 @@ alias vim="nvim"
alias vi="nvim"
alias python="python3"
# If wsl.conf exists we're probably in WSL and need some changes for terminal commands to work correctly
[[ ! -f /etc/wsl.conf ]] || source ~/.wslrc.zsh
[[ ! -f ~/.localrc.zsh ]] || source ~/.localrc.zsh