mirror of
https://github.com/kristoferssolo/SoloVim.git
synced 2025-10-21 20:10:41 +00:00
Changed flake8 to ruff
This commit is contained in:
parent
ab213ef300
commit
a7e28fe683
2
init.lua
2
init.lua
@ -6,6 +6,7 @@ require("user.autocommands")
|
||||
require("user.cmp")
|
||||
require("user.cmp_gh_source")
|
||||
require("user.telescope")
|
||||
require("user.todo")
|
||||
require("user.treesitter")
|
||||
require("user.autopairs")
|
||||
require("user.comment")
|
||||
@ -27,3 +28,4 @@ require("user.crates")
|
||||
require("user.colorizer")
|
||||
require("user.luasnip")
|
||||
require("user.autosave")
|
||||
require("user.persistence")
|
||||
|
||||
@ -4,8 +4,9 @@ if not status_ok then
|
||||
end
|
||||
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
dashboard.section.header.val = {
|
||||
|
||||
local function header()
|
||||
return {
|
||||
[[ ___ ]],
|
||||
[[ /\_ \ __ ]],
|
||||
[[ ____ ___\//\ \ ___ __ __ /\_\ ___ ___ ]],
|
||||
@ -13,21 +14,29 @@ dashboard.section.header.val = {
|
||||
[[/\__, `\/\ \L\ \\_\ \_/\ \L\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
|
||||
[[\/\____/\ \____//\____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]],
|
||||
[[ \/___/ \/___/ \/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]],
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button("f", " " .. " Find file", ":Telescope find_files <cr>"),
|
||||
dashboard.button("e", " " .. " New file", ":ene <BAR> startinsert <cr>"),
|
||||
dashboard.button("p", " " .. " Find project", ":lua require('telescope').extensions.projects.projects()<cr>"),
|
||||
dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles <cr>"),
|
||||
dashboard.button("t", " " .. " Find text", ":Telescope live_grep <cr>"),
|
||||
dashboard.button("c", " " .. " Config", ":e ~/.config/nvim/init.lua <cr>"),
|
||||
dashboard.button("q", " " .. " Quit", ":qa<cr>"),
|
||||
}
|
||||
local function footer()
|
||||
return "kristofers.xyz"
|
||||
end
|
||||
|
||||
dashboard.section.header.val = header()
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button("f", " " .. " Find file", "<cmd>Telescope find_files <cr>"),
|
||||
dashboard.button("e", " " .. " New file", "<cmd>ene <BAR> startinsert <cr>"),
|
||||
dashboard.button("p", " " .. " Persistence", "<cmd>lua require('persistence').load()<cr>"),
|
||||
dashboard.button("r", " " .. " Recent files", "<cmd>Telescope oldfiles <cr>"),
|
||||
dashboard.button("t", " " .. " Find text", "<cmd>Telescope live_grep <cr>"),
|
||||
dashboard.button(
|
||||
"P",
|
||||
" " .. " Find project",
|
||||
"<cmd>lua require('telescope').extensions.projects.projects()<cr>"
|
||||
),
|
||||
dashboard.button("g", " " .. " Git", "<cmd>lua _LAZYGIT_TOGGLE()<cr>"),
|
||||
dashboard.button("c", " " .. " Config", "<cmd>e ~/.config/nvim/init.lua <cr>"),
|
||||
dashboard.button("q", " " .. " Quit", "<cmd>qa<cr>"),
|
||||
}
|
||||
dashboard.section.footer.val = footer()
|
||||
|
||||
dashboard.section.footer.opts.hl = "Type"
|
||||
|
||||
@ -48,7 +48,6 @@ vim.api.nvim_create_autocmd({ "TextYankPost" }, {
|
||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
-- vim.lsp.buf.format({ async = true })
|
||||
end,
|
||||
})
|
||||
|
||||
@ -59,6 +58,15 @@ vim.api.nvim_create_autocmd({ "InsertEnter" }, {
|
||||
end,
|
||||
})
|
||||
|
||||
-- Disable `expandtab` (don't replace tab with spaces) for lua files
|
||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
pattern = { "lua" },
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = false
|
||||
end,
|
||||
})
|
||||
|
||||
-- Set tab size for the following file types to 2
|
||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
pattern = { "vimwiki", "java", "sql" },
|
||||
callback = function()
|
||||
|
||||
@ -4,7 +4,7 @@ if not status_ok then
|
||||
end
|
||||
|
||||
colorizer.setup({
|
||||
filetypes = { "html", "css", "js" },
|
||||
filetypes = { "html", "css", "js", "lua", "yaml", "conf", "toml" },
|
||||
user_default_options = {
|
||||
RGB = true, -- #RGB hex codes
|
||||
RRGGBB = true, -- #RRGGBB hex codes
|
||||
@ -29,6 +29,6 @@ colorizer.setup({
|
||||
},
|
||||
-- all the sub-options of filetypes apply to buftypes
|
||||
buftypes = {},
|
||||
-- html = { names = true },
|
||||
-- css = { names = true },
|
||||
html = { names = true },
|
||||
css = { names = true },
|
||||
})
|
||||
|
||||
@ -33,8 +33,8 @@ comment.setup({
|
||||
---Add comment at the end of line
|
||||
eol = "gcA",
|
||||
},
|
||||
---Enable keybindings
|
||||
---NOTE: If given `false` then the plugin won't create any mappings
|
||||
--- Enable keybindings
|
||||
--- NOTE: If given `false` then the plugin won't create any mappings
|
||||
mappings = {
|
||||
---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}`
|
||||
basic = true,
|
||||
|
||||
@ -33,8 +33,8 @@ keymap("n", "<C-Left>", ":vertical resize -2<cr>", opts)
|
||||
keymap("n", "<C-Right>", ":vertical resize +2<cr>", opts)
|
||||
|
||||
-- -- Navigate buffers
|
||||
-- keymap("n", "<S-l>", ":bnext<cr>", opts)
|
||||
-- keymap("n", "<S-h>", ":bprevious<cr>", opts)
|
||||
keymap("n", "<S-l>", ":bnext<cr>", opts)
|
||||
keymap("n", "<S-h>", ":bprevious<cr>", opts)
|
||||
|
||||
-- Better paste
|
||||
keymap("v", "p", '"_dP', opts)
|
||||
|
||||
@ -89,8 +89,41 @@ end
|
||||
|
||||
ls.add_snippets(nil, {
|
||||
all = {},
|
||||
lua = {},
|
||||
rust = {},
|
||||
lua = {
|
||||
s(
|
||||
"status",
|
||||
fmt(
|
||||
[[
|
||||
local status_ok, {} = pcall(require, "{}")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
same(1),
|
||||
}
|
||||
)
|
||||
),
|
||||
},
|
||||
rust = {
|
||||
s(
|
||||
"modtest",
|
||||
fmt(
|
||||
[[
|
||||
#[cfg(test)]
|
||||
mod test {{
|
||||
{}
|
||||
{}
|
||||
}}
|
||||
]],
|
||||
{
|
||||
c(1, { t(" use super::*"), t("") }),
|
||||
i(0),
|
||||
}
|
||||
)
|
||||
),
|
||||
},
|
||||
python = {},
|
||||
cpp = {
|
||||
s(
|
||||
|
||||
@ -23,7 +23,7 @@ M.setup = function()
|
||||
end
|
||||
|
||||
local config = {
|
||||
virtual_text = false, -- disable virtual text
|
||||
virtual_text = true, -- virtual text
|
||||
signs = {
|
||||
active = signs, -- show signs
|
||||
},
|
||||
@ -55,12 +55,11 @@ local function lsp_keymaps(bufnr)
|
||||
local opts = { noremap = true, silent = true }
|
||||
local keymap = vim.api.nvim_buf_set_keymap
|
||||
keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>", opts)
|
||||
keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>", opts)
|
||||
keymap(bufnr, "n", "gd", "<cmd>lua require('telescope.builtin').lsp_definitions()<cr>", opts)
|
||||
keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", opts)
|
||||
keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<cr>", opts)
|
||||
keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<cr>", opts)
|
||||
keymap(bufnr, "n", "gr", "<cmd>lua require('telescope.builtin').lsp_references()<cr>", opts)
|
||||
keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<cr>", opts)
|
||||
vim.cmd([[command! Format execute "lua vim.lsp.buf.format()"]])
|
||||
end
|
||||
|
||||
M.on_attach = function(client, bufnr)
|
||||
|
||||
@ -23,11 +23,11 @@ local servers = {
|
||||
"jsonls",
|
||||
"lua_ls",
|
||||
"phpactor",
|
||||
"ruff_lsp",
|
||||
"rust_analyzer",
|
||||
"taplo",
|
||||
"texlab",
|
||||
"tsserver",
|
||||
"yamlls",
|
||||
}
|
||||
|
||||
mason.setup()
|
||||
|
||||
@ -16,7 +16,6 @@ mason_null_ls.setup({
|
||||
"codespell",
|
||||
"cpplint",
|
||||
"djlint",
|
||||
"flake8",
|
||||
"gitlint",
|
||||
"html_lint",
|
||||
"isort",
|
||||
@ -45,7 +44,6 @@ null_ls.setup({
|
||||
sources = {
|
||||
diagnostics.codespell,
|
||||
diagnostics.cpplint,
|
||||
diagnostics.flake8,
|
||||
diagnostics.luacheck.with({
|
||||
extra_args = {
|
||||
"--globals",
|
||||
@ -54,7 +52,6 @@ null_ls.setup({
|
||||
}),
|
||||
diagnostics.misspell,
|
||||
diagnostics.mypy,
|
||||
-- diagnostics.phpcs,
|
||||
formatting.autopep8,
|
||||
formatting.beautysh,
|
||||
formatting.clang_format,
|
||||
|
||||
@ -31,7 +31,7 @@ local options = {
|
||||
laststatus = 3,
|
||||
showcmd = false,
|
||||
ruler = false,
|
||||
numberwidth = 4, -- set number column width to 2 {default 4}
|
||||
numberwidth = 4, -- set number column width to 4 {default 4}
|
||||
signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
|
||||
wrap = false, -- display lines as one long line
|
||||
scrolloff = 8, -- is one of my fav
|
||||
|
||||
10
lua/user/persistence.lua
Normal file
10
lua/user/persistence.lua
Normal file
@ -0,0 +1,10 @@
|
||||
local status_ok, persistence = pcall(require, "persistence")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
persistence.setup({
|
||||
dir = vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/"), -- directory where session files are saved
|
||||
options = { "buffers", "curdir", "tabpages", "winsize" }, -- sessionoptions used for saving
|
||||
pre_save = nil, -- a function to call before saving the session
|
||||
})
|
||||
@ -40,7 +40,6 @@ packer.init({
|
||||
|
||||
-- Install your plugins here
|
||||
return packer.startup(function(use)
|
||||
-- My plugins here
|
||||
use("wbthomason/packer.nvim") -- Have packer manage itself
|
||||
use("nvim-lua/plenary.nvim") -- Useful lua functions used by lots of plugins
|
||||
use("windwp/nvim-autopairs") -- Autopairs, integrates with both cmp and treesitter
|
||||
@ -56,12 +55,19 @@ return packer.startup(function(use)
|
||||
use("lewis6991/impatient.nvim")
|
||||
use("lukas-reineke/indent-blankline.nvim")
|
||||
use("goolord/alpha-nvim")
|
||||
use("folke/which-key.nvim")
|
||||
use("andweeb/presence.nvim")
|
||||
use("NvChad/nvim-colorizer.lua")
|
||||
use("alvan/vim-closetag")
|
||||
use("tpope/vim-surround")
|
||||
|
||||
use("folke/which-key.nvim")
|
||||
use("folke/todo-comments.nvim")
|
||||
use({
|
||||
"folke/persistence.nvim",
|
||||
event = "BufReadPre", -- this will only start session saving when an actual file was opened
|
||||
module = "persistence",
|
||||
})
|
||||
|
||||
-- Colorschemes
|
||||
use("lunarvim/darkplus.nvim")
|
||||
use("Mofiqul/dracula.nvim")
|
||||
@ -107,6 +113,8 @@ return packer.startup(function(use)
|
||||
use({ "nvim-telescope/telescope.nvim", run = ":TSUpdate" })
|
||||
use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" })
|
||||
use("nvim-telescope/telescope-media-files.nvim")
|
||||
use("xiyaowong/telescope-emoji.nvim")
|
||||
use("nvim-telescope/telescope-frecency.nvim")
|
||||
|
||||
-- Treesitter
|
||||
use("nvim-treesitter/nvim-treesitter")
|
||||
|
||||
@ -6,7 +6,7 @@ project.setup({
|
||||
-- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project
|
||||
detection_methods = { "pattern" },
|
||||
-- patterns used to detect root dir, when **"pattern"** is in detection_methods
|
||||
patterns = { ".git", "Makefile", "package.json", ".venv" },
|
||||
patterns = { ".git", "Makefile", "package.json", ".venv", "Cargo.toml", "requirements.txt" },
|
||||
})
|
||||
|
||||
local tele_status_ok, telescope = pcall(require, "telescope")
|
||||
|
||||
@ -7,12 +7,10 @@ local actions = require("telescope.actions")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
|
||||
prompt_prefix = " ",
|
||||
selection_caret = " ",
|
||||
path_display = { "smart" },
|
||||
file_ignore_patterns = { ".git/", "node_modules" },
|
||||
|
||||
mappings = {
|
||||
i = {
|
||||
["<Down>"] = actions.cycle_history_next,
|
||||
@ -22,4 +20,33 @@ telescope.setup({
|
||||
},
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true, -- false will only do exact matching
|
||||
override_generic_sorter = true, -- override the generic sorter
|
||||
override_file_sorter = true, -- override the file sorter
|
||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||
},
|
||||
media_files = {
|
||||
-- filetypes whitelist
|
||||
filetypes = { "png", "webp", "jpg", "jpeg", "mp4", "webm" },
|
||||
find_cmd = "rg",
|
||||
},
|
||||
emoji = {
|
||||
action = function(emoji)
|
||||
-- argument emoji is a table.
|
||||
-- {name="", value="", cagegory="", description=""}
|
||||
|
||||
vim.fn.setreg("*", emoji.value)
|
||||
print([[Press p or "*p to paste this emoji]] .. emoji.value)
|
||||
|
||||
-- insert emoji when picked
|
||||
-- vim.api.nvim_put({ emoji.value }, 'c', false, true)
|
||||
end,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
telescope.load_extension("fzf")
|
||||
telescope.load_extension("media_files")
|
||||
telescope.load_extension("emoji")
|
||||
|
||||
69
lua/user/todo.lua
Normal file
69
lua/user/todo.lua
Normal file
@ -0,0 +1,69 @@
|
||||
local status_ok, todo = pcall(require, "todo-comments")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
todo.setup({
|
||||
signs = true, -- show icons in the signs column
|
||||
sign_priority = 8, -- sign priority
|
||||
-- keywords recognized as todo comments
|
||||
keywords = {
|
||||
FIX = {
|
||||
icon = " ", -- icon used for the sign, and in search results
|
||||
color = "error", -- can be a hex color, or a named color (see below)
|
||||
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
|
||||
-- signs = false, -- configure signs for some keywords individually
|
||||
},
|
||||
TODO = { icon = " ", color = "info" },
|
||||
HACK = { icon = " ", color = "warning" },
|
||||
WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } },
|
||||
PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
|
||||
NOTE = { icon = " ", color = "hint", alt = { "INFO" } },
|
||||
TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
|
||||
},
|
||||
gui_style = {
|
||||
fg = "NONE", -- The gui style to use for the fg highlight group.
|
||||
bg = "BOLD", -- The gui style to use for the bg highlight group.
|
||||
},
|
||||
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
|
||||
-- highlighting of the line containing the todo comment
|
||||
-- * before: highlights before the keyword (typically comment characters)
|
||||
-- * keyword: highlights of the keyword
|
||||
-- * after: highlights after the keyword (todo text)
|
||||
highlight = {
|
||||
multiline = true, -- enable multine todo comments
|
||||
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
|
||||
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
|
||||
before = "", -- "fg" or "bg" or empty
|
||||
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
|
||||
after = "fg", -- "fg" or "bg" or empty
|
||||
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
|
||||
comments_only = true, -- uses treesitter to match keywords in comments only
|
||||
max_line_len = 400, -- ignore lines longer than this
|
||||
exclude = {}, -- list of file types to exclude highlighting
|
||||
},
|
||||
-- list of named colors where we try to extract the guifg from the
|
||||
-- list of highlight groups or use the hex color if hl not found as a fallback
|
||||
colors = {
|
||||
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
|
||||
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
|
||||
info = { "DiagnosticInfo", "#2563EB" },
|
||||
hint = { "DiagnosticHint", "#10B981" },
|
||||
default = { "Identifier", "#7C3AD" },
|
||||
test = { "Identifier", "#FF00FF" },
|
||||
},
|
||||
search = {
|
||||
command = "rg",
|
||||
args = {
|
||||
"--color=never",
|
||||
"--no-heading",
|
||||
"--with-filename",
|
||||
"--line-number",
|
||||
"--column",
|
||||
},
|
||||
-- regex that will be used to match keywords.
|
||||
-- don't replace the (KEYWORDS) placeholder
|
||||
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
|
||||
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
|
||||
},
|
||||
})
|
||||
@ -209,6 +209,8 @@ local mappings = {
|
||||
t = { "<cmd>Telescope live_grep<cr>", "Text" },
|
||||
k = { "<cmd>Telescope keymaps<cr>", "Keymaps" },
|
||||
C = { "<cmd>Telescope commands<cr>", "Commands" },
|
||||
T = { "<cmd>TodoTelescope<cr>", "Todo" },
|
||||
m = { "<cmd>lua require('telescope').extensions.media_files.media_files()<cr>", "Media" },
|
||||
p = {
|
||||
"<cmd>lua require('telescope.builtin').colorscheme({enable_preview = true})<cr>",
|
||||
"Colorscheme with Preview",
|
||||
@ -259,6 +261,12 @@ local mappings = {
|
||||
T = { "<cmd>lua require('dap').terminate()<cr>", "Terminate" },
|
||||
l = { "<cmd>lua require('dap').run_last()<cr>", "Run last" },
|
||||
},
|
||||
q = {
|
||||
name = "Persistence",
|
||||
s = { "<cmd>lua require('persistence').load()<cr>", "Current directory" },
|
||||
l = { "<cmd>lua require('persistence').load({ last = true })<cr>", "Last session" },
|
||||
d = { "<cmd>lua require('persistence').stop()<cr>", "Stop" },
|
||||
},
|
||||
}
|
||||
|
||||
which_key.setup(setup)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user