Refactoring

- Added macos
This commit is contained in:
foozzi 2024-01-14 23:29:33 -05:00
parent 03a7616e8c
commit 2c1ccaffd1
47 changed files with 76 additions and 33 deletions

View file

@ -0,0 +1,17 @@
local config = function()
require("ts_context_commentstring").setup({
enable_autocmd = false,
})
require("Comment").setup({
pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(),
})
end
return {
"numToStr/Comment.nvim",
opts = config,
lazy = false,
dependencies = {
{ "JoosepAlviste/nvim-ts-context-commentstring" },
},
}

View file

@ -0,0 +1,22 @@
return {
"stevearc/conform.nvim",
opts = {
icon = "", --'▎',
formatters_by_ft = {
lua = { "stylua" },
python = { "ruff_format", "ruff_fix", "isort" },
javascript = { "biome" },
typescript = { "biome" },
javascriptreact = { "biome" },
typescriptreact = { "biome" },
json = { "biome" },
sh = { "shfmt" },
["*"] = { "trim_whitespace", "codespell" },
},
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
},
lazy = false,
}

View file

@ -0,0 +1,8 @@
return {
"m4xshen/hardtime.nvim",
dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" },
opts = {
max_time = 0,
},
lazy = false,
}

View file

@ -0,0 +1,6 @@
return {
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {},
lazy = false,
}

View file

@ -0,0 +1,16 @@
return {
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 900
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
},
{ "folke/neodev.nvim" },
}

View file

@ -0,0 +1,186 @@
local config = function()
local lsp_zero = require("lsp-zero")
local luasnip = require("luasnip")
local diagnostic_signs = require("utils.icons").diagnostic_signs
lsp_zero.on_attach(function(_, bufnr)
vim.diagnostic.config({
virtual_text = false, -- disable virtual text
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
})
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded",
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded",
})
local opts = { buffer = bufnr, remap = false }
vim.keymap.set("n", "gd", function()
vim.lsp.buf.definition()
end, opts)
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover()
end, opts)
vim.keymap.set("n", "<leader>vws", function()
vim.lsp.buf.workspace_symbol()
end, opts)
vim.keymap.set("n", "<leader>vd", function()
vim.diagnostic.open_float()
end, opts)
vim.keymap.set("n", "[d", function()
vim.diagnostic.goto_next()
end, opts)
vim.keymap.set("n", "]d", function()
vim.diagnostic.goto_prev()
end, opts)
vim.keymap.set("n", "<leader>ca", function()
vim.lsp.buf.code_action()
end, opts)
vim.keymap.set("n", "<leader>vrr", function()
vim.lsp.buf.references()
end, opts)
vim.keymap.set("n", "<leader>vrn", function()
vim.lsp.buf.rename()
end, opts)
vim.keymap.set("i", "<C-h>", function()
vim.lsp.buf.signature_help()
end, opts)
vim.keymap.set("n", "<leader>gi", function()
vim.lsp.buf.implementation()
end, opts)
-- nvim-lint
vim.keymap.set("n", "<leader>li", function()
require("lint").try_lint()
end, opts)
-- conform
vim.keymap.set("n", "<leader>fr", function()
require("conform").format({ bufnr = bufnr })
end, opts)
end)
lsp_zero.set_sign_icons({
error = diagnostic_signs.Error,
warn = diagnostic_signs.Warn,
hint = diagnostic_signs.Hint,
info = diagnostic_signs.Info,
})
require("mason").setup({})
require("mason-lspconfig").setup({
ensure_installed = {
"bashls",
"tsserver",
"pyright",
"lua_ls",
"jsonls",
"clangd",
"biome", -- will install for formatting only
},
automatic_installation = true,
handlers = {
lsp_zero.default_setup,
lua_ls = function()
local lua_opts = lsp_zero.nvim_lua_ls()
require("lspconfig").lua_ls.setup(lua_opts)
end,
pyright = function()
require("lspconfig").pyright.setup({
settings = {
python = {
analysis = {
typeCheckingMode = "off",
},
},
},
})
end,
biome = function() -- use tsserver instead
return {}
end,
},
})
local cmp = require("cmp")
local cmp_select = { behavior = cmp.SelectBehavior.Select }
require("luasnip/loaders/from_vscode").lazy_load()
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
preselect = "item",
completion = {
completeopt = "menu,menuone,noinsert",
},
sources = {
{ name = "luasnip" },
{ name = "path" },
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "buffer" },
},
formatting = lsp_zero.cmp_format(),
mapping = cmp.mapping.preset.insert({
-- ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
["<Tab>"] = cmp.mapping.select_next_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
["<C-f>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<C-b>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
})
end
return {
"VonHeikemen/lsp-zero.nvim",
branch = "v3.x",
config = config,
lazy = false,
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip",
{
"L3MON4D3/LuaSnip",
version = "v2.*",
build = "make install_jsregexp",
dependencies = { "rafamadriz/friendly-snippets" },
},
},
}

View file

@ -0,0 +1,69 @@
local config = {
options = {
icons_enabled = true,
theme = "auto",
globalstatus = true,
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
component_separators = { left = "|", right = "|" },
section_separators = { left = "", right = "" },
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
sections = {
lualine_a = { "mode" },
lualine_b = { "" },
lualine_x = { "diagnostics", "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
lualine_c = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
}
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
local function ins_right(component)
table.insert(config.sections.lualine_x, 1, component)
end
ins_right({
-- Lsp server name .
function()
local msg = "No Active Lsp"
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end,
icon = " LSP:",
color = { fg = "#ff6b6b" },
})
return {
"nvim-lualine/lualine.nvim",
lazy = false,
opts = config,
dependencies = {
"nvim-tree/nvim-web-devicons",
},
}

View file

@ -0,0 +1,14 @@
return {
"williamboman/mason.nvim",
cmd = "Mason",
event = "BufReadPre",
opts = {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
},
}

View file

@ -0,0 +1,7 @@
return {
"karb94/neoscroll.nvim",
config = function()
require("neoscroll").setup({})
end,
lazy = false,
}

View file

@ -0,0 +1,17 @@
local config = function()
local Rule = require("nvim-autopairs.rule")
local conds = require("nvim-autopairs.conds")
local npairs = require("nvim-autopairs")
require("nvim-autopairs").setup({})
npairs.add_rule(Rule('"""', '"""', "python"):with_pair(function()
return false
end))
end
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
config = config, -- this is equalent to setup({}) function
}

View file

@ -0,0 +1,16 @@
return {
"akinsho/bufferline.nvim",
opts = {
options = {
-- diagnostics = "nvim_lsp",
always_show_bufferline = false,
offsets = {
{ filetype = "NvimTree", text = "File Explorer", highlight = "Directory", text_align = "left" },
},
},
},
dependencies = {
"nvim-tree/nvim-web-devicons",
},
event = "VeryLazy",
}

View file

@ -0,0 +1,18 @@
local config = function()
require("lint").linters_by_ft = {
python = { "mypy" },
}
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
require("lint").try_lint()
end,
})
end
return {
"mfussenegger/nvim-lint",
opts = {},
config = config,
lazy = false,
}

View file

@ -0,0 +1,9 @@
return {
"nvim-tree/nvim-tree.lua",
lazy = false,
opts = {
filters = {
dotfiles = false,
},
},
}

View file

@ -0,0 +1,52 @@
local config = function()
require("nvim-treesitter.configs").setup({
build = ":TSUpdate",
indent = {
enable = true,
},
autotag = {
enable = true,
},
event = {
"BufReadPre",
"BufNewFile",
},
ensure_installed = {
"markdown",
"json",
"javascript",
"typescript",
"yaml",
"html",
"css",
"markdown",
"bash",
"lua",
"dockerfile",
"solidity",
"gitignore",
"python",
"vue",
},
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = true,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-s>",
node_incremental = "<C-s>",
scope_incremental = false,
node_decremental = "<BS>",
},
},
})
end
return {
"nvim-treesitter/nvim-treesitter",
lazy = false,
opts = config,
}

View file

@ -0,0 +1,4 @@
return {
"windwp/nvim-ts-autotag",
lazy = false,
}

View file

@ -0,0 +1,3 @@
return {
"nvim-tree/nvim-web-devicons",
}

View file

@ -0,0 +1,4 @@
return {
"preservim/tagbar",
lazy = false,
}

View file

@ -0,0 +1,45 @@
local mapvimkey = require("utils.keymapper").mapvimkey
local config = function()
local telescope = require("telescope")
telescope.setup({
defaults = {
mappings = {
i = {
["<C-j>"] = "move_selection_next",
["<C-k>"] = "move_selection_previous",
},
},
},
pickers = {
find_files = {
theme = "dropdown",
previewer = true,
hidden = true,
},
live_grep = {
theme = "dropdown",
previewer = true,
},
buffers = {
theme = "dropdown",
previewer = true,
},
},
})
end
return {
"nvim-telescope/telescope.nvim",
tag = "0.1.3",
lazy = false,
dependencies = { "nvim-lua/plenary.nvim" },
config = config,
keys = {
mapvimkey("<leader>fk", "Telescope keymaps", "Show Keymaps"),
mapvimkey("<leader>fh", "Telescope help_tags", "Show Help Tags"),
mapvimkey("<leader>ff", "Telescope find_files", "Find Files"),
mapvimkey("<leader>fg", "Telescope live_grep", "Live Grep"),
mapvimkey("<leader>fb", "Telescope buffers", "Find Buffers"),
},
}

View file

@ -0,0 +1,4 @@
return {
"christoomey/vim-tmux-navigator",
lazy = false,
}

View file

@ -0,0 +1,9 @@
return {
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
opts = {},
config = function()
vim.cmd("colorscheme tokyonight-storm")
end,
}

View file

@ -0,0 +1,82 @@
local diagnostic_signs = require("utils.icons").diagnostic_signs
local maplazykey = require("utils.keymapper").maplazykey
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {
position = "bottom", -- position of the list can be: bottom, top, left, right
height = 10, -- height of the trouble list when position is top or bottom
width = 50, -- width of the list when position is left or right
icons = true, -- use devicons for filenames
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
fold_open = "", -- icon used for open folds
fold_closed = "", -- icon used for closed folds
group = true, -- group results by file
padding = true, -- add an extra new line on top of the list
cycle_results = true, -- cycle item list when reaching beginning or end of list
action_keys = { -- key mappings for actions in the trouble list
-- map to {} to remove a mapping, for example:
-- close = {},
close = "q", -- close the list
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
refresh = "r", -- manually refresh
jump = { "<cr>", "<tab>", "<2-leftmouse>" }, -- jump to the diagnostic or open / close folds
open_split = { "<c-x>" }, -- open buffer in new split
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
open_tab = { "<c-t>" }, -- open buffer in new tab
jump_close = { "o" }, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
switch_severity = "s", -- switch "diagnostics" severity filter level to HINT / INFO / WARN / ERROR
toggle_preview = "P", -- toggle auto_preview
hover = "K", -- opens a small popup with the full multiline message
preview = "p", -- preview the diagnostic location
open_code_href = "c", -- if present, open a URI with more information about the diagnostic error
close_folds = { "zM", "zm" }, -- close all folds
open_folds = { "zR", "zr" }, -- open all folds
toggle_fold = { "zA", "za" }, -- toggle fold of current file
previous = "k", -- previous item
next = "j", -- next item
help = "?", -- help menu
},
multiline = true, -- render multi-line messages
indent_lines = true, -- add an indent guide below the fold icons
win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|.
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
include_declaration = { "lsp_references", "lsp_implementations", "lsp_definitions" }, -- for the given modes, include the declaration of the current symbol in the results
signs = {
-- icons / text used for a diagnostic
error = diagnostic_signs.Error,
warning = diagnostic_signs.Warn,
hint = diagnostic_signs.Hint,
information = diagnostic_signs.Info,
other = diagnostic_signs.Info,
},
use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client
},
keys = {
maplazykey("<leader>xx", function()
require("trouble").toggle()
end, "Toggle Trouble"),
maplazykey("<leader>xw", function()
require("trouble").toggle("workspace_diagnostics")
end, "Show Workspace Diagnostics"),
maplazykey("<leader>xd", function()
require("trouble").toggle("document_diagnostics")
end, "Show Document Diagnostics"),
maplazykey("<leader>xq", function()
require("trouble").toggle("quickfix")
end, "Toggle Quickfix List"),
maplazykey("<leader>xl", function()
require("trouble").toggle("loclist")
end, "Toggle Location List"),
maplazykey("gR", function()
require("trouble").toggle("lsp_references")
end, "Toggle LSP References"),
},
}

View file

@ -0,0 +1,7 @@
return {
"RRethy/vim-illuminate",
lazy = false,
config = function()
require("illuminate").configure({})
end,
}