diff --git a/config/nvim/.gitignore b/config/nvim/.gitignore new file mode 100644 index 0000000..6d635cb --- /dev/null +++ b/config/nvim/.gitignore @@ -0,0 +1 @@ +/plugin diff --git a/config/nvim/Makefile b/config/nvim/Makefile new file mode 100644 index 0000000..303cd2c --- /dev/null +++ b/config/nvim/Makefile @@ -0,0 +1,5 @@ +fmt: + @stylua {lua,init.lua} + +lint: + @selene {lua,init.lua} diff --git a/config/nvim/ftplugin/go.lua b/config/nvim/ftplugin/go.lua new file mode 100644 index 0000000..62b2624 --- /dev/null +++ b/config/nvim/ftplugin/go.lua @@ -0,0 +1,6 @@ +local ok, dapi = pcall(require, "dap-install") +if not ok then + return +end + +dapi.config("go_delve", {}) diff --git a/config/nvim/ftplugin/javascript.lua b/config/nvim/ftplugin/javascript.lua new file mode 100644 index 0000000..abff1e3 --- /dev/null +++ b/config/nvim/ftplugin/javascript.lua @@ -0,0 +1,6 @@ +local ok, dapi = pcall(require, "dap-install") +if not ok then + return +end + +dapi.config("jsnode", {}) diff --git a/config/nvim/ftplugin/lua.lua b/config/nvim/ftplugin/lua.lua new file mode 100644 index 0000000..27f97af --- /dev/null +++ b/config/nvim/ftplugin/lua.lua @@ -0,0 +1,6 @@ +local ok, dapi = pcall(require, "dap-install") +if not ok then + return +end + +dapi.config("lua", {}) diff --git a/config/nvim/ftplugin/python.lua b/config/nvim/ftplugin/python.lua new file mode 100644 index 0000000..7fa4b3e --- /dev/null +++ b/config/nvim/ftplugin/python.lua @@ -0,0 +1,6 @@ +local ok, dapi = pcall(require, "dap-install") +if not ok then + return +end + +dapi.config("python", {}) diff --git a/config/nvim/init.lua b/config/nvim/init.lua new file mode 100644 index 0000000..19e1a90 --- /dev/null +++ b/config/nvim/init.lua @@ -0,0 +1,9 @@ +require "options" +require "plugin" +require "keymapings" +require "disabled" +require "globals" +require "autocmd" + +vim.g.vscode_style = "dark" +vim.cmd [[colo vscode]] diff --git a/config/nvim/lua/autocmd.lua b/config/nvim/lua/autocmd.lua new file mode 100644 index 0000000..0f4b928 --- /dev/null +++ b/config/nvim/lua/autocmd.lua @@ -0,0 +1 @@ +vim.cmd [[ autocmd BufWritePre * lua mkdir() ]] diff --git a/config/nvim/lua/disabled.lua b/config/nvim/lua/disabled.lua new file mode 100644 index 0000000..5024ca8 --- /dev/null +++ b/config/nvim/lua/disabled.lua @@ -0,0 +1,26 @@ +local disabled_built_ins = { + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "gzip", + "zip", + "tohtml", + "man", + "zipPlugin", + "tar", + "tarPlugin", + "getscript", + "getscriptPlugin", + "vimball", + "vimballPlugin", + "2html_plugin", + "logipat", + "rrhelper", + "spellfile_plugin", + "matchit", +} + +for _, plugin in pairs(disabled_built_ins) do + vim.g["loaded_" .. plugin] = 1 +end diff --git a/config/nvim/lua/globals.lua b/config/nvim/lua/globals.lua new file mode 100644 index 0000000..287d03a --- /dev/null +++ b/config/nvim/lua/globals.lua @@ -0,0 +1,10 @@ +function _G.term_cmd(cmd) + require("toggleterm.terminal").Terminal:new({ cmd = cmd, hidden = true }):toggle() +end + +function _G.mkdir() + local dir = vim.fn.expand "%:p:h" + if vim.fn.isdirectory(dir) == 0 then + vim.fn.mkdir(dir, "p") + end +end diff --git a/config/nvim/lua/keymapings.lua b/config/nvim/lua/keymapings.lua new file mode 100644 index 0000000..fda9ce3 --- /dev/null +++ b/config/nvim/lua/keymapings.lua @@ -0,0 +1,78 @@ +local u = require "utils" +local map, nmap, expr = u.map, u.nmap, u.expr + +nmap("", "write!") +nmap("h", "nohlsearch") +nmap("q", "quit!") +nmap("w", "write!") +nmap("e", "NvimTreeToggle") +nmap("/", "lua require[[Comment]].toggle()") +map("v", "/", "gc") +nmap("ps", "PackerSync") + +-- Windows +for _, k in ipairs { "h", "j", "k", "l" } do + nmap(string.format("", k), string.format("wincmd %s", k)) + map("t", string.format("", k), string.format("%s", k)) +end + +nmap("", "vertical resize -2") +nmap("resize -1") +nmap("", "resize +2") +nmap("", "vertical resize +2") + +-- Alternative up/down for arrows +expr("i", "", 'pumvisible() ? "\\" : "\\"') +expr("i", "", 'pumvisible() ? "\\" : "\\"') +expr("c", "", 'pumvisible() ? "\\" : "\\"') +expr("c", "", 'pumvisible() ? "\\" : "\\"') + +-- Move line +map("i", "", ":m .+1==gi") +map("i", "", ":m .-2==gi") +map("v", "K", ":move '<-2gv-gv") +map("v", "J", ":move '>+1gv-gv") +nmap("", ":m .+1==") +nmap("", ":m .-2==") + +-- Telescope +nmap("f", "Telescope find_files") +nmap("b", "Telescope buffers") +nmap("st", "Telescope live_grep") +nmap("sT", "Telescope grep_string") +nmap("sp", "Telescope projects") +nmap("sr", "Telescope oldfiles") +nmap("sb", "Telescope git_branches") +nmap("sc", "Telescope git_commits") +nmap("sk", "Telescope keymaps") + +-- Terminal +nmap("gg", "lua term_cmd('lazygit')") +nmap("D", " lua term_cmd('lazydocker')") + +-- DAP +nmap("dt", "lua require'dap'.toggle_breakpoint()") +nmap("db", "lua require'dap'.step_back()") +nmap("dc", "lua require'dap'.continue()") +nmap("dd", "lua require'dap'.disconnect()") +nmap("di", "lua require'dap'.step_into()") +nmap("do", "lua require'dap'.step_over()") +nmap("du", "lua require'dap'.step_out()") +nmap("dr", "lua require'dap'.repl.toggle()") +nmap("dp", "lua require'dap'.pause.toggle()") +nmap("dq", "lua require'dap'.close()") + +-- Ultest +nmap("tt", "Ultest") +nmap("ts", "UltestStop") +nmap("tc", "UltestClear") +nmap("tn", "UltestNearest") +nmap("to", "UltestOutput") + +-- Buffer +nmap("", "BufferLast") +nmap("", "BufferClose") +nmap("c", "BufferClose!") +for i = 1, 9 do + nmap(string.format("", i), string.format("BufferGoto %d", i)) +end diff --git a/config/nvim/lua/lsp/attach.lua b/config/nvim/lua/lsp/attach.lua new file mode 100644 index 0000000..4f3e488 --- /dev/null +++ b/config/nvim/lua/lsp/attach.lua @@ -0,0 +1,26 @@ +return function(client, bufnr) + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") + client.resolved_capabilities.document_formatting = false + client.resolved_capabilities.document_range_formatting = false + + local function buf_map(...) + vim.api.nvim_buf_set_keymap(bufnr, "n", ...) + end + + local opts = { noremap = true, silent = true } + buf_map("K", "lua vim.lsp.buf.hover()", opts) + buf_map("gd", "lua vim.lsp.buf.definition()", opts) + buf_map("gD", "lua vim.lsp.buf.declaration()", opts) + buf_map("gr", "lua vim.lsp.buf.references()", opts) + buf_map("gI", "lua vim.lsp.buf.implementation()", opts) + buf_map("gs", "lua vim.lsp.buf.signature_help()", opts) + buf_map("gl", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) + buf_map("la", "Telescope lsp_code_actions", opts) + buf_map("lA", "lua vim.lsp.buf.range_code_action()", opts) + buf_map("ld", "TroubleToggle", opts) + buf_map("lr", "lua vim.lsp.buf.rename()", opts) + buf_map("lf", "lua vim.lsp.buf.formatting()", opts) + buf_map("ls", "Telescope lsp_document_symbols", opts) + buf_map("li", "LspInfo", opts) + buf_map("lR", "LspRestart", opts) +end diff --git a/config/nvim/lua/lsp/init.lua b/config/nvim/lua/lsp/init.lua new file mode 100644 index 0000000..bfc8f94 --- /dev/null +++ b/config/nvim/lua/lsp/init.lua @@ -0,0 +1,22 @@ +local on_attach = require "lsp.attach" +local M = {} + +function M.setup() + require("nvim-lsp-installer").on_server_ready(function(server) + local opts = { on_attach = on_attach } + + local ok, server_opts = pcall(require, "lsp.providers." .. server.name) + if ok then + opts = vim.tbl_deep_extend("force", opts, server_opts or {}) + end + + server:setup(opts) + + vim.cmd [[ do User LspAttachBuffers ]] + + require("lsp.null").setup() + require("lspconfig")["null-ls"].setup {} + end) +end + +return M diff --git a/config/nvim/lua/lsp/null.lua b/config/nvim/lua/lsp/null.lua new file mode 100644 index 0000000..e784bd1 --- /dev/null +++ b/config/nvim/lua/lsp/null.lua @@ -0,0 +1,38 @@ +local M = {} + +function M.setup() + local null_ls = require "null-ls" + + local fmt = null_ls.builtins.formatting + local lint = null_ls.builtins.diagnostics + + null_ls.config { + sources = { + -- Lua + fmt.stylua, + lint.selene, + + -- Golang + fmt.gofumpt, + fmt.goimports, + + -- JavaScirpt + fmt.prettierd, + lint.eslint_d, + + -- Shell + fmt.shfmt, + lint.shellcheck, + + -- Python + fmt.black, + fmt.isort, + lint.flake8, + + -- Rust + fmt.rustfmt, + }, + } +end + +return M diff --git a/config/nvim/lua/lsp/providers/jsonls.lua b/config/nvim/lua/lsp/providers/jsonls.lua new file mode 100644 index 0000000..299c0ba --- /dev/null +++ b/config/nvim/lua/lsp/providers/jsonls.lua @@ -0,0 +1,16 @@ +return { + settings = { + schemaDownload = { + enable = true, + }, + schemas = { + { fileMatch = { "package.json" }, url = "https://json.schemastore.org/package.json" }, + { url = "https://json.schemastore.org/tsconfig.json", fileMatch = { "tsconfig.json", "tsconfig.*.json" } }, + { url = "https://json.schemastore.org/lerna.json", fileMatch = { "lerna.json" } }, + { url = "https://json.schemastore.org/eslintrc.json", fileMatch = { ".eslintrc.json", ".eslintrc" } }, + { url = "https://json.schemastore.org/prettierrc", fileMatch = { ".prettierrc", ".prettierrc.json", "prettier.config.json" } }, + { fileMatch = { ".golangci.toml", ".golangci.json" }, url = "https://json.schemastore.org/golangci-lint.json" }, + { fileMatch = { "package.json" }, url = "https://json.schemastore.org/package.json" }, + }, + }, +} diff --git a/config/nvim/lua/lsp/providers/pyright.lua b/config/nvim/lua/lsp/providers/pyright.lua new file mode 100644 index 0000000..52f8013 --- /dev/null +++ b/config/nvim/lua/lsp/providers/pyright.lua @@ -0,0 +1,8 @@ +return { + python = { + analysis = { + autoSearchPaths = true, + useLibraryCodeForTypes = false, + }, + }, +} diff --git a/config/nvim/lua/lsp/providers/sqls.lua b/config/nvim/lua/lsp/providers/sqls.lua new file mode 100644 index 0000000..9ce7bcd --- /dev/null +++ b/config/nvim/lua/lsp/providers/sqls.lua @@ -0,0 +1,12 @@ +return { + settings = { + sqls = { + connections = { + { + driver = "postgresql", + dataSourceName = "host=0.0.0.0 port=5432 user=postgres password=qwerty123 dbname=postgres sslmode=disable", + }, + }, + }, + }, +} diff --git a/config/nvim/lua/lsp/providers/sumneko_lua.lua b/config/nvim/lua/lsp/providers/sumneko_lua.lua new file mode 100644 index 0000000..5d5f657 --- /dev/null +++ b/config/nvim/lua/lsp/providers/sumneko_lua.lua @@ -0,0 +1,15 @@ +return { + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, + }, + }, + }, +} diff --git a/config/nvim/lua/lsp/providers/tsserver.lua b/config/nvim/lua/lsp/providers/tsserver.lua new file mode 100644 index 0000000..8cce0be --- /dev/null +++ b/config/nvim/lua/lsp/providers/tsserver.lua @@ -0,0 +1,19 @@ +return { + setup = { + handlers = { + ["textDocument/publishDiagnostics"] = function(_, _, p, id, _, cfg) + if p.diagnostics ~= nil then + local i = 1 + while i <= #p.diagnostics do + if p.diagnostics[i].code == 80001 then + table.remove(p.diagnostics, i) + else + i = i + 1 + end + end + end + vim.lsp.diagnostic.on_publish_diagnostics(_, _, p, id, _, cfg) + end, + }, + }, +} diff --git a/config/nvim/lua/lsp/providers/yamlls.lua b/config/nvim/lua/lsp/providers/yamlls.lua new file mode 100644 index 0000000..e874923 --- /dev/null +++ b/config/nvim/lua/lsp/providers/yamlls.lua @@ -0,0 +1,14 @@ +return { + settings = { + yaml = { + hover = true, + completion = true, + validate = true, + schemaStore = { + enable = true, + url = "https://www.schemastore.org/api/json/catalog.json", + }, + schemas = {}, + }, + }, +} diff --git a/config/nvim/lua/options.lua b/config/nvim/lua/options.lua new file mode 100644 index 0000000..be901d5 --- /dev/null +++ b/config/nvim/lua/options.lua @@ -0,0 +1,47 @@ +local o = vim.opt + +vim.g.mapleader = " " +vim.g.maplocalleader = "," +vim.g.netrw_banner = false + +-- o.laststatus = 0 +o.backup = false +o.clipboard = "unnamedplus" +o.cmdheight = 1 +o.colorcolumn = "99999" +o.completeopt = { "menuone", "noselect" } +o.conceallevel = 0 +o.fileencoding = "utf-8" +o.foldmethod = "manual" +o.foldexpr = "" +o.guifont = "JetBrains Mono Nerd Font:h17" +o.hidden = true +o.hlsearch = true +o.ignorecase = true +o.mouse = "a" +o.pumheight = 10 +o.showmode = false +o.smartcase = true +o.smartindent = true +o.splitbelow = true +o.splitright = true +o.swapfile = false +o.termguicolors = true +-- o.timeoutlen = 100 +o.title = true +o.undofile = true +o.updatetime = 300 +o.writebackup = false +o.expandtab = true +o.shiftwidth = 2 +o.tabstop = 2 +o.cursorline = true +o.number = true +o.relativenumber = true +o.numberwidth = 4 +o.signcolumn = "yes" +o.wrap = false +o.spell = false +o.spelllang = "en" +o.scrolloff = 8 +o.sidescrolloff = 8 diff --git a/config/nvim/lua/plugin.lua b/config/nvim/lua/plugin.lua new file mode 100644 index 0000000..46c4b6b --- /dev/null +++ b/config/nvim/lua/plugin.lua @@ -0,0 +1,163 @@ +return require("packer").startup(function(use) + use "wbthomason/packer.nvim" + use "nvim-lua/plenary.nvim" + use "Mofiqul/vscode.nvim" + use "kyazdani42/nvim-web-devicons" + use "romgrk/barbar.nvim" + use { "dstein64/vim-startuptime", cmd = "StartupTime" } + + use { + "pwntester/octo.nvim", + cmd = "Octo", + opt = true, + config = function() + require("octo").setup() + end, + } + + use { + "numToStr/Comment.nvim", + config = function() + require("Comment").setup() + end, + } + + use { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup() + end, + } + + use { + "neovim/nvim-lspconfig", + requires = { + "williamboman/nvim-lsp-installer", + { "jose-elias-alvarez/null-ls.nvim", after = "nvim-lspconfig" }, + }, + config = function() + require("lsp").setup() + end, + } + + use { + "ahmedkhalf/project.nvim", + config = function() + require("plugin.project").setup() + end, + } + + use { + "mfussenegger/nvim-dap", + module = "dap", + requires = { + { "Pocco81/DAPInstall.nvim", requires = "nvim-dap" }, + { "theHamsta/nvim-dap-virtual-text", after = "nvim-dap", config = [[ require"nvim-dap-virtual-text".setup() ]] }, + { "nvim-telescope/telescope-dap.nvim", after = "nvim-dap", config = [[ require("telescope").load_extension "dap" ]] }, + }, + config = function() + require("plugin.dap").setup() + end, + } + + use { + "ray-x/go.nvim", + ft = "go", + opt = true, + config = function() + require("go").setup { gofmt = "gofumpt" } + end, + } + + use { + "lewis6991/gitsigns.nvim", + config = function() + require("plugin.gitsigns").setup() + end, + } + + use { + "nvim-lualine/lualine.nvim", + config = function() + require("plugin.statusline").setup() + end, + } + + use { + "rcarriga/vim-ultest", + requires = { { "vim-test/vim-test", after = "vim-ultest" } }, + cmd = { "Ultest", "UltestStop", "UltestClear", "UltestNearest", "UltestOutput" }, + run = ":UpdateRemotePlugins", + config = function() + require("plugin.ultest").setup() + end, + } + + use { + "hrsh7th/nvim-cmp", + requires = { + { "hrsh7th/cmp-nvim-lua", after = "nvim-cmp" }, + { "hrsh7th/cmp-nvim-lsp", after = "nvim-cmp" }, + { "hrsh7th/cmp-buffer", after = "nvim-cmp" }, + { + "saadparwaiz1/cmp_luasnip", + requires = { + { "L3MON4D3/LuaSnip", after = "cmp_luasnip" }, + { "rafamadriz/friendly-snippets", after = "LuaSnip" }, + }, + }, + }, + config = function() + require("plugin.cmp").setup() + end, + } + + use { + "max397574/better-escape.nvim", + config = function() + require("better_escape").setup { mapping = { "jk" } } + end, + } + + use { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + module = "telescope", + config = function() + require("plugin.telescope").setup() + end, + } + + use { + "kyazdani42/nvim-tree.lua", + cmd = "NvimTreeToggle", + config = function() + require("plugin.nvimtree").setup() + end, + } + + use { + "nvim-treesitter/nvim-treesitter", + branch = "0.5-compat", + config = function() + require("plugin.treesitter").setup() + end, + } + + use { + "Smirnov-O/ts-unit.nvim", + after = "nvim-treesitter", + config = function() + require("ts-unit").setup { keymaps = true } + end, + } + + use { + "akinsho/toggleterm.nvim", + module = "toggleterm", + keys = "", + config = function() + require("plugin.terminal").setup() + end, + } +end) diff --git a/config/nvim/lua/plugin/cmp.lua b/config/nvim/lua/plugin/cmp.lua new file mode 100644 index 0000000..b7a7f9c --- /dev/null +++ b/config/nvim/lua/plugin/cmp.lua @@ -0,0 +1,68 @@ +local M = {} + +function M.setup() + local cmp = require "cmp" + + require("luasnip/loaders/from_vscode").lazy_load { + paths = { "~/.local/share/nvim/site/pack/packer/start/friendly-snippets" }, + } + + cmp.event:on("confirm_done", require("nvim-autopairs.completion.cmp").on_confirm_done()) + cmp.setup { + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + formatting = { + format = function(entry, vim_item) + vim_item.menu = ({ + nvim_lsp = "(L)", + nvim_lua = "(N)", + buffer = "(B)", + luasnip = "(S)", + })[entry.source.name] + + return vim_item + end, + }, + mapping = { + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + else + fallback() + end + end, + [""] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, + }, + sources = { + { name = "nvim_lua", max_item_count = 5 }, + { name = "nvim_lsp", max_item_count = 8 }, + { name = "buffer", keyword_length = 4, max_item_count = 5 }, + { name = "luasnip", max_item_count = 4, keyword_length = 2 }, + }, + experimental = { + ghost_text = true, + }, + } +end + +return M diff --git a/config/nvim/lua/plugin/dap.lua b/config/nvim/lua/plugin/dap.lua new file mode 100644 index 0000000..8e81392 --- /dev/null +++ b/config/nvim/lua/plugin/dap.lua @@ -0,0 +1,24 @@ +local M = {} + +function M.setup() + vim.fn.sign_define("DapBreakpoint", { + text = "", + texthl = "LspDiagnosticsSignError", + linehl = "", + numhl = "", + }) + vim.fn.sign_define("DapBreakpointRejected", { + text = "", + texthl = "LspDiagnosticsSignHint", + linehl = "", + numhl = "", + }) + vim.fn.sign_define("DapStopped", { + text = "", + texthl = "LspDiagnosticsSignInformation", + linehl = "DiagnosticUnderlineInfo", + numhl = "LspDiagnosticsSignInformation", + }) +end + +return M diff --git a/config/nvim/lua/plugin/gitsigns.lua b/config/nvim/lua/plugin/gitsigns.lua new file mode 100644 index 0000000..b8d2881 --- /dev/null +++ b/config/nvim/lua/plugin/gitsigns.lua @@ -0,0 +1,53 @@ +local M = {} + +function M.setup() + require("gitsigns").setup { + signs = { + add = { hl = "GitSignsAdd", text = "│", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "│", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "_", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "‾", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "~", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + keymaps = { + noremap = true, + ["n gs"] = 'lua require"gitsigns".stage_hunk()', + ["n gr"] = 'lua require"gitsigns".reset_hunk()', + ["n gR"] = 'lua require"gitsigns".reset_buffer()', + ["n gp"] = 'lua require"gitsigns".preview_hunk()', + ["n gl"] = 'lua require"gitsigns".blame_line(true)', + ["n gS"] = 'lua require"gitsigns".stage_buffer()', + ["n gU"] = 'lua require"gitsigns".reset_buffer_index()', + }, + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 300, + }, + current_line_blame_formatter_opts = { relative_time = false }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, + max_file_length = 40000, + preview_config = { + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + yadm = { enable = false }, + } +end + +return M diff --git a/config/nvim/lua/plugin/nvimtree.lua b/config/nvim/lua/plugin/nvimtree.lua new file mode 100644 index 0000000..dfd96c8 --- /dev/null +++ b/config/nvim/lua/plugin/nvimtree.lua @@ -0,0 +1,44 @@ +local M = {} + +function M.setup() + local tree_cb = require("nvim-tree.config").nvim_tree_callback + + require("nvim-tree").setup { + disable_netrw = true, + hijack_netrw = true, + auto_close = true, + auto_open = true, + update_cwd = false, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + filters = { + dotfiles = true, + custom = { ".git", "node_modules", "__pycache__", "env", ".bin" }, + }, + view = { + width = 30, + side = "left", + auto_resize = false, + mappings = { + custom_only = false, + list = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + }, + } + + vim.g.nvim_tree_group_empty = 1 + vim.g.nvim_tree_indent_markers = 1 +end + +return M diff --git a/config/nvim/lua/plugin/project.lua b/config/nvim/lua/plugin/project.lua new file mode 100644 index 0000000..383ac9a --- /dev/null +++ b/config/nvim/lua/plugin/project.lua @@ -0,0 +1,15 @@ +local M = {} + +function M.setup() + require("project_nvim").setup { + manual_mode = false, + detection_methods = { "lsp", "pattern" }, + patterns = { ".git", ".svn", "Makefile", "package.json", "go.mod" }, + ignore_lsp = {}, + exclude_dirs = {}, + show_hidden = false, + silent_chdir = true, + } +end + +return M diff --git a/config/nvim/lua/plugin/statusline.lua b/config/nvim/lua/plugin/statusline.lua new file mode 100644 index 0000000..16f2ee2 --- /dev/null +++ b/config/nvim/lua/plugin/statusline.lua @@ -0,0 +1,22 @@ +local M = {} + +function M.setup() + require("lualine").setup { + options = { + theme = "codedark", + component_separators = { "", "" }, + section_separators = { "", "" }, + disabled_filetypes = { "NvimTree", "Telescope" }, + }, + sections = { + lualine_a = { "branch", "diff" }, + lualine_b = { "filename" }, + lualine_c = {}, + lualine_x = {}, + lualine_y = { { "diagnostics", sources = { "nvim_lsp" } } }, + lualine_z = { "location" }, + }, + } +end + +return M diff --git a/config/nvim/lua/plugin/telescope.lua b/config/nvim/lua/plugin/telescope.lua new file mode 100644 index 0000000..cacc26f --- /dev/null +++ b/config/nvim/lua/plugin/telescope.lua @@ -0,0 +1,52 @@ +local M = {} + +function M.setup() + local actions = require "telescope.actions" + + require("telescope").setup { + defaults = { + prompt_prefix = " ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "descending", + layout_strategy = "horizontal", + layout_config = { + width = 0.75, + preview_cutoff = 120, + prompt_position = "top", + horizontal = { mirror = false }, + vertical = { mirror = false }, + }, + file_ignore_patterns = { ".git", "node_modules", "__pycache__", "target", "env", ".bin" }, + path_display = { shorten = 5 }, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = true, + set_env = { ["COLORTERM"] = "truecolor" }, + pickers = { + find_files = { find_command = { "fd", "--type=file", "--hidden", "--smart-case" } }, + live_grep = { only_sort_text = true }, + }, + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = false, + + [""] = "which_key", + }, + n = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + }, + }, + } + + require("telescope").load_extension "projects" +end + +return M diff --git a/config/nvim/lua/plugin/terminal.lua b/config/nvim/lua/plugin/terminal.lua new file mode 100644 index 0000000..15ad8fd --- /dev/null +++ b/config/nvim/lua/plugin/terminal.lua @@ -0,0 +1,28 @@ +local M = {} + +function M.setup() + require("toggleterm").setup { + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = false, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + winblend = 0, + highlights = { + border = "Normal", + background = "Normal", + }, + }, + } +end + +return M diff --git a/config/nvim/lua/plugin/treesitter.lua b/config/nvim/lua/plugin/treesitter.lua new file mode 100644 index 0000000..14ad230 --- /dev/null +++ b/config/nvim/lua/plugin/treesitter.lua @@ -0,0 +1,20 @@ +local M = {} + +function M.setup() + require("nvim-treesitter.configs").setup { + ensure_installed = { "lua", "go", "gomod" }, + highlight = { enable = true }, + indent = { enable = true, disable = { "python", "yml" } }, + autotag = { enable = true }, + context_commentstring = { enable = true }, + rainbow = { + enable = false, + extended_mode = true, + max_file_lines = 500, + }, + } + + local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() +end + +return M diff --git a/config/nvim/lua/plugin/ultest.lua b/config/nvim/lua/plugin/ultest.lua new file mode 100644 index 0000000..6b8ce9b --- /dev/null +++ b/config/nvim/lua/plugin/ultest.lua @@ -0,0 +1,7 @@ +local M = {} + +function M.setup() + vim.g["test#go#gotest#optiongs"] = "-v" +end + +return M diff --git a/config/nvim/lua/utils.lua b/config/nvim/lua/utils.lua new file mode 100644 index 0000000..37ca28e --- /dev/null +++ b/config/nvim/lua/utils.lua @@ -0,0 +1,27 @@ +local M = {} + +M.opts = { noremap = true, silent = true } + +function M._map(mode, from, to, opts) + vim.api.nvim_set_keymap(mode, from, to, opts) +end + +function M.map(mode, from, to) + if type(mode) == "table" then + for _, m in pairs(mode) do + M._map(m, from, to, M.opts) + end + end + + M._map(mode, from, to, M.opts) +end + +function M.nmap(from, to) + M._map("n", from, to, M.opts) +end + +function M.expr(mode, from, to) + M._map(mode, from, to, { noremap = true, expr = true }) +end + +return M diff --git a/config/nvim/selene.toml b/config/nvim/selene.toml new file mode 100644 index 0000000..6540d6f --- /dev/null +++ b/config/nvim/selene.toml @@ -0,0 +1 @@ +std="lua51+vim" diff --git a/config/nvim/stylua.toml b/config/nvim/stylua.toml new file mode 100644 index 0000000..ff09851 --- /dev/null +++ b/config/nvim/stylua.toml @@ -0,0 +1,6 @@ +column_width = 140 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +no_call_parentheses = true diff --git a/config/nvim/vim.toml b/config/nvim/vim.toml new file mode 100644 index 0000000..937afa0 --- /dev/null +++ b/config/nvim/vim.toml @@ -0,0 +1,5 @@ +[vim] +any = true + +[_G] +any = true