From 746fa4ff3563693d4ed23861bf3fcf134da68e60 Mon Sep 17 00:00:00 2001 From: deazen Date: Wed, 14 Aug 2024 03:43:41 +0400 Subject: [PATCH] First commit --- .gitignore | 3 ++ init.lua | 9 ++++++ lua/config/lazy.lua | 25 ++++++++++++++ lua/config/mason-tools-list.lua | 9 ++++++ lua/keymaps.lua | 15 +++++++++ lua/plugins/colorscheme.lua | 11 +++++++ lua/plugins/lualine.lua | 43 +++++++++++++++++++++++++ lua/plugins/mason-tool-installer.lua | 6 ++++ lua/plugins/mason.lua | 6 ++++ lua/plugins/neo-tree.lua | 31 ++++++++++++++++++ lua/plugins/nvim-conform.lua | 19 +++++++++++ lua/plugins/nvim-lint.lua | 19 +++++++++++ lua/plugins/telescope.lua | 10 ++++++ lua/plugins/treesitter-text-objects.lua | 4 +++ lua/plugins/treesitter.lua | 31 ++++++++++++++++++ 15 files changed, 241 insertions(+) create mode 100644 .gitignore create mode 100644 init.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/mason-tools-list.lua create mode 100644 lua/keymaps.lua create mode 100644 lua/plugins/colorscheme.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/mason-tool-installer.lua create mode 100644 lua/plugins/mason.lua create mode 100644 lua/plugins/neo-tree.lua create mode 100644 lua/plugins/nvim-conform.lua create mode 100644 lua/plugins/nvim-lint.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter-text-objects.lua create mode 100644 lua/plugins/treesitter.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1dba02a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +lazy-lock.json +lazyvim.json + diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..a0f9651 --- /dev/null +++ b/init.lua @@ -0,0 +1,9 @@ +vim.opt.clipboard = "unnamed,unnamedplus" + +vim.opt.tabstop = 4 -- Количество пробелов, которое занимает табуляция +vim.opt.shiftwidth = 4 -- Количество пробелов при автоотступах +vim.opt.expandtab = true -- Преобразует табуляцию в пробелы +vim.wo.relativenumber = true + +require("config.lazy") +require("keymaps") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..6db5f8a --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,25 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +require("lazy").setup({ + + spec = { + { import = "plugins" }, + }, +}) diff --git a/lua/config/mason-tools-list.lua b/lua/config/mason-tools-list.lua new file mode 100644 index 0000000..d981c69 --- /dev/null +++ b/lua/config/mason-tools-list.lua @@ -0,0 +1,9 @@ +local to_install = { + "stylua", + "ruff", + "isort", + "mypy", + "basedpyright", +} + +return to_install diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..4c75e54 --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,15 @@ +local keymap = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } + +-- Remap Ctrl + h to move to the left window +keymap("n", "", "h", opts) + +-- Remap Ctrl + j to move to the window below +keymap("n", "", "j", opts) + +-- Remap Ctrl + k to move to the window above +keymap("n", "", "k", opts) + +-- Remap Ctrl + l to move to the right window +keymap("n", "", "l", opts) + diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..fbb5b26 --- /dev/null +++ b/lua/plugins/colorscheme.lua @@ -0,0 +1,11 @@ +return { + "briones-gabriel/darcula-solid.nvim", + dependencies = { + "rktjmp/lush.nvim", + }, + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + vim.cmd([[colorscheme darcula-solid]]) + end, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..fdb0c83 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,43 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + options = { + icons_enabled = true, + theme = "powerline", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + lualine_x = { "encoding", "filetype" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, + }, +} diff --git a/lua/plugins/mason-tool-installer.lua b/lua/plugins/mason-tool-installer.lua new file mode 100644 index 0000000..12c5556 --- /dev/null +++ b/lua/plugins/mason-tool-installer.lua @@ -0,0 +1,6 @@ +return { + "WhoIsSethDaniel/mason-tool-installer.nvim", + opts = { + ensure_installed = require("config.mason-tools-list"), + }, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..2f3a14f --- /dev/null +++ b/lua/plugins/mason.lua @@ -0,0 +1,6 @@ +return { + "williamboman/mason.nvim", + opts = { + ensure_installed = require("config.mason-tools-list"), + }, +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..181972f --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,31 @@ +local setup = { + source_selector = { + winbar = true, -- toggle to show selector on winbar + statusline = false, -- toggle to show selector on statusline + show_scrolled_off_parent_node = false, -- this will replace the tabs with the parent path + -- of the top visible node when scrolled down. + sources = { + { source = "filesystem" }, + { source = "buffers" }, + { source = "git_status" }, + }, + }, +} + +return { + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function() + require("neo-tree").setup(setup) + -- Define key mappings here to ensure they are set after the plugin is loaded + vim.api.nvim_set_keymap("n", "n", "Neotree toggle", { noremap = true, silent = true }) + end, + keys = "n", -- Optionally specify here to load the plugin on this keypress + }, +} diff --git a/lua/plugins/nvim-conform.lua b/lua/plugins/nvim-conform.lua new file mode 100644 index 0000000..72e4fe4 --- /dev/null +++ b/lua/plugins/nvim-conform.lua @@ -0,0 +1,19 @@ +return { + "stevearc/conform.nvim", + opts = {}, + config = function() + require("conform").setup({ + formatters_by_ft = { + lua = { "stylua" }, + python = { "isort", "ruff_format" }, + }, + }) + vim.api.nvim_set_keymap( + "n", + "f", + ":lua require('conform').format()", + { noremap = true, silent = true } + ) + end, + keys = "f", -- Optionally specify here to load the plugin on this keypress +} diff --git a/lua/plugins/nvim-lint.lua b/lua/plugins/nvim-lint.lua new file mode 100644 index 0000000..60f64cc --- /dev/null +++ b/lua/plugins/nvim-lint.lua @@ -0,0 +1,19 @@ +return { + "mfussenegger/nvim-lint", + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + python = { "ruff", "mypy" }, + } + + 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, + }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..7f459e6 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,10 @@ +return { + "nvim-telescope/telescope.nvim", + tag = "0.1.8", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("telescope").setup({}) -- Define key mappings here to ensure they are set after the plugin is loaded + vim.api.nvim_set_keymap("n", "", "Telescope live_grep", { noremap = true, silent = true }) + end, + keys = "", -- Optionally specify here to load the plugin on this keypress +} diff --git a/lua/plugins/treesitter-text-objects.lua b/lua/plugins/treesitter-text-objects.lua new file mode 100644 index 0000000..6070234 --- /dev/null +++ b/lua/plugins/treesitter-text-objects.lua @@ -0,0 +1,4 @@ +return { + "nvim-treesitter/nvim-treesitter-textobjects", + dependencies = { "nvim-treesitter/nvim-treesitter" }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..0fa806f --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,31 @@ +local langs = { + "lua", + "javascript", + "typescript", + "python", + "go", + "html", + "css", + "scss", + "json", + "php", + "tsx", + "sql", +} + +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = langs, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, + }, +}