diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index b9b3429..c6b0eb8 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,2 +1,2 @@ -require("plugins") require("settings") +require("config.lazy") diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..aad855e --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,14 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--single-branch", + "https://github.com/folke/lazy.nvim.git", + lazypath, + }) +end +vim.opt.runtimepath:prepend(lazypath) + +require("lazy").setup("config.plugins") diff --git a/.config/nvim/lua/config/plugins/cmp.lua b/.config/nvim/lua/config/plugins/cmp.lua new file mode 100644 index 0000000..bbb5fc8 --- /dev/null +++ b/.config/nvim/lua/config/plugins/cmp.lua @@ -0,0 +1,110 @@ +local M = { + "hrsh7th/nvim-cmp", + dependencies = { + "andersevenrud/cmp-tmux", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lsp-signature-help", + "L3MON4D3/LuaSnip", + "onsails/lspkind-nvim", + "saadparwaiz1/cmp_luasnip", + }, + event = "InsertEnter", +} + +function M.config() + local cmp = require("cmp") + local luasnip = require("luasnip") + + local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + + cmp.setup({ + formatting = { + format = require("lspkind").cmp_format({ + with_text = true, + menu = { + buffer = "[Buffer]", + tmux = "[Tmux]", + luasnip = "[LuaSnip]", + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + path = "[Path]", + }, + }), + }, + + window = { + completion = cmp.config.window.bordered({ + winhighlight = "Normal:PMenu,FloatBorder:PMenuBorder,CursorLine:PMenuSel,Search:None", + }), + documentation = cmp.config.window.bordered({ + winhighlight = "Normal:PMenu,FloatBorder:PMenu,CursorLine:PMenuSel,Search:None", + }), + }, + + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + + mapping = { + [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [""] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, + + sources = cmp.config.sources({ + { name = "buffer", priority = 1 }, + { name = "luasnip", priority = 4 }, + { name = "copilot", group_index = 5 }, + { + name = "tmux", + priority = 2, + option = { + all_panes = true, + trigger_characters = {}, + }, + }, + { name = "nvim_lsp", priority = 3 }, + { name = "nvim_lsp_signature_help", priority = 4 }, + }), + }) +end + +return M diff --git a/.config/nvim/lua/config/plugins/copilot.lua b/.config/nvim/lua/config/plugins/copilot.lua new file mode 100644 index 0000000..24a6f6a --- /dev/null +++ b/.config/nvim/lua/config/plugins/copilot.lua @@ -0,0 +1,54 @@ +local M = { + "zbirenbaum/copilot.lua", + event = { "VeryLazy" }, + dependencies = { + { + "zbirenbaum/copilot-cmp", + config = function() + require("copilot_cmp").setup() + end, + }, + }, +} + +function M.config() + require("copilot").setup({ + panel = { + enabled = true, + auto_refresh = false, + keymap = { + jump_prev = "[[", + jump_next = "]]", + accept = "", + refresh = "gr", + open = "", + }, + }, + suggestion = { + enabled = true, + auto_trigger = true, + debounce = 75, + keymap = { + accept = "", + next = "", + prev = "", + dismiss = "", + }, + }, + filetypes = { + yaml = false, + markdown = false, + help = false, + gitcommit = false, + gitrebase = false, + hgcommit = false, + svn = false, + cvs = false, + ["."] = false, + }, + copilot_node_command = "node", -- Node version must be < 18 + server_opts_overrides = {}, + }) +end + +return M diff --git a/.config/nvim/lua/config/plugins/dap.lua b/.config/nvim/lua/config/plugins/dap.lua new file mode 100644 index 0000000..aeec64d --- /dev/null +++ b/.config/nvim/lua/config/plugins/dap.lua @@ -0,0 +1,39 @@ +local M = { + "mfussenegger/nvim-dap", + + dependencies = { + { "rcarriga/nvim-dap-ui" }, + { + "theHamsta/nvim-dap-virtual-text", + config = function() + require("nvim-dap-virtual-text").setup({ + commented = true, + }) + end, + }, + { + "leoluz/nvim-dap-go", + config = function() + require("dap-go").setup() + end, + keys = { + { "y", ":lua require('dap-go').debug_test()" }, + }, + }, + }, +} + +function M.init() + local silent = { silent = true } + vim.fn.sign_define("DapStopped", { text = "⇒", texthl = "", linehl = "debugPC", numhl = "" }) + vim.fn.sign_define("DapBreakpoint", { text = "🧘", texthl = "", linehl = "debugPC", numhl = "" }) + vim.keymap.set("n", "DD", ":lua require 'dap'.toggle_breakpoint()", silent) + vim.keymap.set("n", "Dc", ":lua require 'dap'.continue()", silent) + vim.keymap.set("n", "Di", ":lua require 'dap'.step_into()", silent) + vim.keymap.set("n", "Do", ":lua require 'dap'.step_over()", silent) + vim.keymap.set("n", "DO", ":lua require 'dap'.step_out()", silent) + vim.keymap.set("n", "Dr", ":lua require 'dap'.repl.toggle({height = 5})", silent) + vim.keymap.set("n", "Dh", ":lua require 'dap.ui.widgets'.hover()", silent) +end + +return M diff --git a/.config/nvim/lua/config/plugins/init.lua b/.config/nvim/lua/config/plugins/init.lua new file mode 100644 index 0000000..de97660 --- /dev/null +++ b/.config/nvim/lua/config/plugins/init.lua @@ -0,0 +1,122 @@ +return { + "hashivim/vim-terraform", + "pierreglaser/folding-nvim", + "tjdevries/colorbuddy.vim", + "wbthomason/packer.nvim", + "jose-elias-alvarez/nvim-lsp-ts-utils", + "jjo/vim-cue", + "ckipp01/stylua-nvim", + + { + "numToStr/Comment.nvim", + keys = { + { "", "(comment_toggle_linewise_current)" }, + { "", "(comment_toggle_linewise_visual)", mode = "v" }, + }, + dependencies = { + "JoosepAlviste/nvim-ts-context-commentstring", + }, + config = function() + require("Comment").setup({ + pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(), + }) + end, + }, + + { + "L3MON4D3/LuaSnip", + config = function() + require("luasnip/loaders/from_vscode").lazy_load() + end, + }, + + { + "lewis6991/gitsigns.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + require("gitsigns").setup({ + numhl = true, + 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", + }, + }, + }) + end, + }, + + { + "lukas-reineke/indent-blankline.nvim", + branch = "master", + event = "VeryLazy", + init = function() + vim.g.indent_blankline_char = "│" + vim.g.indent_blankline_space_char = "⬝" + vim.g.indent_blankline_space_char_highlight_list = { "IndentSpace" } + -- vim.g.indent_blankline_char_list = {'|', '¦', '┆', '┊'} + vim.g.indent_blankline_buftype_exclude = { "help", "terminal" } + vim.g.indent_blankline_filetype_exclude = { "text", "markdown" } + -- vim.g.indent_blankline_show_end_of_line = true + vim.g.indent_blankline_show_first_indent_level = true + vim.g.indent_blankline_show_trailing_blankline_indent = true + vim.g.indent_blankline_char_highlight_list = + { "Indent1", "Indent2", "Indent3", "Indent4", "Indent5", "Indent6" } + require("indent_blankline").setup({}) + end, + }, + + { + "ray-x/go.nvim", + config = function() + require("go").setup({ + comment_placeholder = "", + icons = { breakpoint = "🧘", currentpos = "🏃" }, + dap_debug_gui = false, + }) + vim.cmd("autocmd FileType go nmap c :lua require('go.comment').gen()") + vim.cmd("autocmd BufWritePre *.go :silent! lua require('go.format').gofmt()") + vim.cmd("autocmd BufWritePre (InsertLeave?) lua vim.lsp.buf.formatting_sync(nil,500)") + end, + }, + + { + "onsails/lspkind-nvim", + config = function() + require("lspkind").init({}) + end, + }, + + { + url = "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + config = function() + require("lsp_lines").setup() + vim.diagnostic.config({ + virtual_text = false, + }) + end, + }, +} diff --git a/.config/nvim/lua/config/plugins/lsp-config.lua b/.config/nvim/lua/config/plugins/lsp-config.lua new file mode 100644 index 0000000..c83c037 --- /dev/null +++ b/.config/nvim/lua/config/plugins/lsp-config.lua @@ -0,0 +1,239 @@ +local M = { + "neovim/nvim-lspconfig", + event = "VeryLazy", +} + +function M.config() + local lspconfig = require("lspconfig") + + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()") + vim.keymap.set("i", "", "lua vim.lsp.buf.signature_help()") + vim.keymap.set("n", "1gd", "lua vim.lsp.buf.type_definition()") + vim.keymap.set("n", "gf", "lua vim.lsp.buf.format()") + vim.keymap.set("n", "rn", "lua vim.lsp.buf.rename()") + vim.keymap.set("n", "[d", "lua vim.lsp.diagnostic.goto_prev()") + vim.keymap.set("n", "]d", "lua vim.lsp.diagnostic.goto_next()") + vim.keymap.set("n", "gwa", "lua vim.lsp.buf.add_workspace_folder()") + vim.keymap.set("n", "gwr", "lua vim.lsp.buf.add_workspace_folder()") + vim.keymap.set("n", "gwl", "lua vim.lsp.buf.add_workspace_folder()") + + vim.cmd([[autocmd BufWritePre * lua vim.lsp.buf.format({sync = true})]]) + + local border = { + { "🭽", "FloatBorder" }, + { "▔", "FloatBorder" }, + { "🭾", "FloatBorder" }, + { "▕", "FloatBorder" }, + { "🭿", "FloatBorder" }, + { "▁", "FloatBorder" }, + { "🭼", "FloatBorder" }, + { "▏", "FloatBorder" }, + } + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }) + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + update_in_insert = false, + virtual_text = false, + }) + + local signs = { Error = "🔥", Warn = "⚠️ ", Hint = "💡", Info = "💡" } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end + + local on_attach = function() + -- require("folding").on_attach() + end + + -- simple setups -- + local servers = { + "bashls", + "dockerls", + "gopls", + "jsonls", + -- "sql", + "pyright", + "sumneko_lua", + "terraformls", + "yamlls", + } + + for _, lsp in ipairs(servers) do + lspconfig[lsp].setup({ on_attach = on_attach }) + end + + local efm_prettier = { + formatCommand = "prettier --stdin-filepath ${INPUT}", + formatStdin = true, + } + + lspconfig.gopls.setup({ + on_attach = on_attach, + settings = { + gopls = { + directoryFilters = { + "-bazel-bin", + "-bazel-out", + "-bazel-testlogs", + "-proto", + }, + }, + }, + }) + + lspconfig.sumneko_lua.setup({ + on_attach = function() + on_attach() + vim.cmd([[autocmd BufWritePre lua require'stylua-nvim'.format_file()]]) + end, + settings = { + Lua = { + completion = { kewordSnippet = "Disable" }, + diagnostics = { + enable = true, + globals = { "renoise", "use", "vim" }, + }, + runtime = { + version = "LuaJIT", + path = { "?.lua", "?/init.lua", "?/?.lua" }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + maxPreload = 2000, + preloadFileSize = 1000, + checkThirdParty = false, + }, + }, + }, + }) + + lspconfig.terraformls.setup({}) + + local yaml_is_k8s = function(bufnr) + local lines = vim.api.nvim_buf_get_lines(bufnr, 0, 50, false) -- Stop after the first 50 lines + for _, l in pairs(lines) do + if string.find(l, "apiVersion") ~= nil then + return true + end + end + return false + end + + lspconfig.cssls.setup({ + cmd = { "vscode-css-languageserver", "--stdio" }, + capabilities = capabilities, + }) + + lspconfig.cssmodules_ls.setup({}) + + lspconfig.html.setup({ + cmd = { "vscode-html-languageserver", "--stdio" }, + filetypes = { "html" }, + init_options = { + configurationSection = { "html", "css", "javascript" }, + embeddedLanguages = { + css = true, + javascript = true, + }, + }, + settings = {}, + }) + + lspconfig.yamlls.setup({ + settings = { + yaml = { + format = { enable = true, singleQuote = true }, + schemaStore = { enable = true, url = "https://json.schemastore.org" }, + schemas = { + -- ["https://json.schemastore.org/github-workflow"] = "*.github/workflows/*", + ["https://json.schemastore.org/kustomization.json"] = "kustomization.yaml", + -- ["https://json.schemastore.org/ansible-role-2.9.json"] = "*/tasks/*.y*ml", + kubernetes = { + "clusterrolebinding.yaml", + "clusterrole-contour.yaml", + "clusterrole.yaml", + "configmap.yaml", + "cronjob.yaml", + "daemonset.yaml", + "deployment-*.yaml", + "deployment.yaml", + "*-deployment.yaml", + "hpa.yaml", + "ingress.yaml", + "job.yaml", + "namespace.yaml", + "pvc.yaml", + "rbac.yaml", + "rolebinding.yaml", + "role.yaml", + "sa.yaml", + "secret.yaml", + "serviceaccounts.yaml", + "service-account.yaml", + "serviceaccount.yaml", + "service-*.yaml", + "service.yaml", + "*-service.yaml", + "statefulset.yaml", + }, + }, + + validate = true, + }, + }, + }) + + require("lspconfig").tsserver.setup({}) + + -- npm install -g typescript typescript-language-server + -- require("lspconfig").tsserver.setup({ + -- on_attach = function(client, bufnr) + -- client.resolved_capabilities.document_formatting = false + -- on_attach(client) + + -- local ts_utils = require("nvim-lsp-ts-utils") + + -- ts_utils.setup({ + -- debug = false, + -- disable_commands = false, + -- enable_import_on_completion = false, + -- import_all_timeout = 5000, -- ms + + -- -- eslint + -- eslint_enable_code_actions = true, + -- eslint_enable_disable_comments = true, + -- eslint_bin = "eslint_d", + -- eslint_config_fallback = nil, + -- eslint_enable_diagnostics = true, + + -- -- formatting + -- enable_formatting = true, + -- formatter = "prettier", + -- formatter_config_fallback = nil, + + -- -- parentheses completion + -- complete_parens = false, + -- signature_help_in_parens = false, + + -- -- update imports on file move + -- update_imports_on_move = true, + -- require_confirmation_on_move = true, + -- watch_dir = nil, + -- }) + + -- ts_utils.setup_client(client) + + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "co", ":TSLspOrganize", { silent = true }) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent", { silent = true }) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "cR", ":TSLspRenameFile", { silent = true }) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "ci", ":TSLspImportAll", { silent = true }) + -- end, + -- }) + -- +end + +return M diff --git a/.config/nvim/lua/config/plugins/lualine.lua b/.config/nvim/lua/config/plugins/lualine.lua new file mode 100644 index 0000000..b18c74c --- /dev/null +++ b/.config/nvim/lua/config/plugins/lualine.lua @@ -0,0 +1,36 @@ +local M = { + "nvim-lualine/lualine.nvim", + dependencies = { "kyazdani42/nvim-web-devicons" }, + event = "VeryLazy", +} + +local function clock() + return os.date("%H:%M") +end + +function M.config() + local lualine = require("lualine") + + lualine.setup({ + options = { + globalstatus = true, + theme = "onelight", + component_separators = { left = "╲", right = "╱" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_c = { + { + "filename", + path = 1, + file_status = true, + }, + }, + lualine_x = { "filetype" }, + lualine_y = { "location", "progress" }, + lualine_z = { clock }, + }, + }) +end + +return M diff --git a/.config/nvim/lua/config/plugins/marks.lua b/.config/nvim/lua/config/plugins/marks.lua new file mode 100644 index 0000000..6226ae3 --- /dev/null +++ b/.config/nvim/lua/config/plugins/marks.lua @@ -0,0 +1,37 @@ +local M = { + "chentoast/marks.nvim", + event = "VeryLazy", +} + +function M.config() + local marks = require("marks") + marks.setup({ + + default_mappings = true, + -- which builtin marks to show. default {} + -- builtin_marks = { ".", "<", ">", "^" }, + + cyclic = true, + force_write_shada = false, + + -- marks, and bookmarks. + -- can be either a table with all/none of the keys, or a single number, in which case + -- the priority applies to all marks. + -- default 10. + -- sign_priority = { lower=10, upper=15, builtin=8, bookmark=20 }, + -- + -- disables mark tracking for specific filetypes. default {} + excluded_filetypes = {}, + + -- marks.nvim allows you to configure up to 10 bookmark groups, each with its own + -- sign/virttext. Bookmarks can be used to group together positions and quickly move + -- across multiple buffers. default sign is '!@#$%^&*()' (from 0 to 9), and + -- default virt_text is "". + bookmark_1 = { + sign = "⚑", + virt_text = "", + }, + }) +end + +return M diff --git a/.config/nvim/lua/config/plugins/null-ls.lua b/.config/nvim/lua/config/plugins/null-ls.lua new file mode 100644 index 0000000..dd43316 --- /dev/null +++ b/.config/nvim/lua/config/plugins/null-ls.lua @@ -0,0 +1,35 @@ +local M = { + "jose-elias-alvarez/null-ls.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, +} + +function M.config() + local null_ls = require("null-ls") + local builtins = require("null-ls.builtins") + + null_ls.setup({ + sources = { + builtins.formatting.black, + builtins.formatting.buf, + builtins.formatting.cue_fmt, + builtins.formatting.shfmt, + builtins.formatting.buildifier, + builtins.completion.spell, + builtins.diagnostics.buf.with({ + args = { "lint", "--disable-symlinks", "--path", "$FILENAME" }, + cwd = function() + local file_dir = vim.fn.expand("%:p:h") .. ";" + local buf_yaml = vim.fn.findfile("buf.yaml", file_dir) + if buf_yaml then + return vim.fn.fnamemodify(buf_yaml, ":h") + end + end, + }), + builtins.diagnostics.buildifier, + builtins.diagnostics.cue_fmt, + }, + debug = true, + }) +end + +return M diff --git a/.config/nvim/lua/config/plugins/osc52.lua b/.config/nvim/lua/config/plugins/osc52.lua new file mode 100644 index 0000000..b788cde --- /dev/null +++ b/.config/nvim/lua/config/plugins/osc52.lua @@ -0,0 +1,18 @@ +local M = { + "ojroques/nvim-osc52", +} + +function M.config() + local osc52 = require("osc52") + osc52.setup({ + max_length = 0, -- Maximum length of selection (0 for no limit) + silent = false, -- Disable message on successful copy + trim = false, -- Trim text before copy + }) + + vim.keymap.set("n", "c", require("osc52").copy_operator, { expr = true }) + vim.keymap.set("n", "cc", "c_", { remap = true }) + vim.keymap.set("x", "c", require("osc52").copy_visual) +end + +return M diff --git a/.config/nvim/lua/config/plugins/telescope.lua b/.config/nvim/lua/config/plugins/telescope.lua new file mode 100644 index 0000000..fcc59b1 --- /dev/null +++ b/.config/nvim/lua/config/plugins/telescope.lua @@ -0,0 +1,94 @@ +local function project_files() + require("telescope.builtin").find_files({ + cwd = require("lspconfig.util").root_pattern(".git")(vim.fn.expand("%:p")), + }) +end + +local M = { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/popup.nvim", + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-fzy-native.nvim", + "nvim-telescope/telescope-github.nvim", + "nvim-telescope/telescope-dap.nvim", + }, +} + +function M.config() + local telescope = require("telescope") + local actions = require("telescope.actions") + local previewers = require("telescope.previewers") + + vim.keymap.set("n", "b", 'lua require("telescope.builtin").buffers()') + vim.keymap.set("n", "f", 'lua require("telescope.builtin").oldfiles()') + vim.keymap.set("n", "", 'lua require("telescope.builtin").oldfiles()') + vim.keymap.set("n", "d", 'lua require("telescope.builtin").diagnostics()') + vim.keymap.set("n", "e", 'lua require("telescope.builtin").git_files()') + vim.keymap.set("n", "g", 'lua require("telescope.builtin").git_status()') + vim.keymap.set("n", "a", 'lua require("telescope.builtin").lsp_code_actions()') + vim.keymap.set("n", "m", 'lua require("telescope.builtin").marks()') + vim.keymap.set("n", "s", 'lua require("telescope.builtin").lsp_document_symbols()') + vim.keymap.set("n", "t", 'lua require("telescope.builtin").treesitter()') + vim.keymap.set("n", "/", 'lua require("telescope.builtin").live_grep()') + vim.keymap.set("n", ".", 'lua require("telescope.builtin").file_browser()') + vim.keymap.set("n", "p", 'lua require("telescope.builtin").registers()') + vim.keymap.set("n", "gr", 'lua require("telescope.builtin").lsp_references()') + vim.keymap.set("n", "gd", 'lua require("telescope.builtin").lsp_definitions()') + vim.keymap.set("n", "g/", 'lua require("telescope.builtin").lsp_document_symbols()') + vim.keymap.set("n", "g?", 'lua require("telescope.builtin").lsp_workspace_symbols()') + vim.keymap.set("n", "ge", 'lua require("telescope.builtin").lsp_document_diagnostics()') + vim.keymap.set("n", "Db", 'lua require("telescope").extensions.dap.list_breakpoints()') + vim.keymap.set("n", "Dcc", 'lua require("telescope").extensions.dap.commands()') + vim.keymap.set("n", "Df", 'lua require("telescope").extensions.dap.frames()') + vim.keymap.set("n", "Dv", 'lua require("telescope").extensions.dap.variables()') + + -- Setup + telescope.setup({ + defaults = { + layout_strategy = "flex", + -- layout_defaults = {flip_columns = 160}, + layout_config = { + preview_cutoff = 10, + }, + mappings = { + i = { + [""] = actions.select_default + actions.center, + [""] = actions.close, + [""] = actions.add_selection, + }, + }, + color_devicons = true, + file_previewer = previewers.vim_buffer_cat.new, + grep_previewer = previewers.vim_buffer_vimgrep.new, + qflist_previewer = previewers.vim_buffer_qflist.new, + }, + }) + + local layout_strategies = require("telescope.pickers.layout_strategies") + local config = require("telescope.config") + + layout_strategies.flex = function(self, max_columns, max_lines) + local layout_config = self.layout_config or {} + + local flip_columns = layout_config.flip_columns or 160 -- Here's why. + local flip_lines = layout_config.flip_lines or 20 + + if max_columns < flip_columns and max_lines > flip_lines then + self.layout_config = (config.values.layout_defaults or {})["vertical"] + return layout_strategies.vertical(self, max_columns, max_lines) + else + self.layout_config = (config.values.layout_defaults or {})["horizontal"] + return layout_strategies.horizontal(self, max_columns, max_lines) + end + end + + -- Extensions + telescope.load_extension("dap") + telescope.load_extension("fzy_native") + telescope.load_extension("gh") + -- telescope.load_extension("packer") -- currently breaking packer + -- +end + +return M diff --git a/.config/nvim/lua/config/plugins/treesitter-context.lua b/.config/nvim/lua/config/plugins/treesitter-context.lua new file mode 100644 index 0000000..5172396 --- /dev/null +++ b/.config/nvim/lua/config/plugins/treesitter-context.lua @@ -0,0 +1,48 @@ +local M = { + "nvim-treesitter/nvim-treesitter-context", + dependencies = { + "nvim-treesitter/nvim-treesitter", + }, +} + +function M.config() + local config = require("treesitter-context") + config.setup({ + enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries. + -- For all filetypes + -- Note that setting an entry here replaces all other patterns for this entry. + -- By setting the 'default' entry below, you can control which nodes you want to + -- appear in the context window. + default = { + "class", + "function", + "method", + -- 'for', -- These won't appear in the context + -- 'while', + -- 'if', + -- 'switch', + -- 'case', + }, + -- Example for a specific filetype. + -- If a pattern is missing, *open a PR* so everyone can benefit. + -- rust = { + -- 'impl_item', + -- }, + }, + exact_patterns = { + -- Example for a specific filetype with Lua patterns + -- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will + -- exactly match "impl_item" only) + -- rust = true, + }, + + -- [!] The options below are exposed but shouldn't require your attention, + -- you can safely ignore them. + + zindex = 20, -- The Z-index of the context window + }) +end + +return M diff --git a/.config/nvim/lua/config/plugins/treesitter.lua b/.config/nvim/lua/config/plugins/treesitter.lua new file mode 100644 index 0000000..a7a5dc7 --- /dev/null +++ b/.config/nvim/lua/config/plugins/treesitter.lua @@ -0,0 +1,70 @@ +return { + { "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" }, + + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "BufReadPost", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + "windwp/nvim-ts-autotag", + }, + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = "all", + highlight = { + enable = true, + use_languagetree = true, + }, + + indent = { + enable = false, + }, + + playground = { + enable = true, + disable = {}, + updatetime = 25, + persist_queries = false, + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = "ss", + node_incremental = "sq", + scope_incremental = "sd", + node_decremental = "sa", + }, + }, + + textobjects = { + move = { + enable = true, + goto_next_start = { + ["]]"] = "@function.outer", + ["]m"] = "@class.outer", + }, + goto_next_end = { + ["]["] = "@function.outer", + ["]M"] = "@class.outer", + }, + goto_previous_start = { + ["[["] = "@function.outer", + ["[m"] = "@class.outer", + }, + goto_previous_end = { + ["[]"] = "@function.outer", + ["[M"] = "@class.outer", + }, + }, + }, + --- nvim-ts-autotag --- + autotag = { + enable = true, + filetypes = { "html", "javascriptreact", "xml" }, + }, + }) + end, + }, +} diff --git a/.config/nvim/lua/config/plugins/yanky.lua b/.config/nvim/lua/config/plugins/yanky.lua new file mode 100644 index 0000000..f22d8e7 --- /dev/null +++ b/.config/nvim/lua/config/plugins/yanky.lua @@ -0,0 +1,24 @@ +local M = { + "folke/yanky.nvim", +} + +function M.config() + require("yanky").setup({ + ring = { + history_length = 100, + storage = "memory", + sync_with_numbered_registers = false, + cancel_event = "update", + }, + }) + + vim.keymap.set({ "n", "x" }, "p", "(YankyPutAfter)") + vim.keymap.set({ "n", "x" }, "P", "(YankyPutBefore)") + vim.keymap.set({ "n", "x" }, "gp", "(YankyGPutAfter)") + vim.keymap.set({ "n", "x" }, "gP", "(YankyGPutBefore)") + + vim.keymap.set("n", "", "(YankyCycleForward)") + vim.keymap.set("n", "", "(YankyCycleBackward)") +end + +return M diff --git a/.config/nvim/lua/config/plugins/zenbones.lua b/.config/nvim/lua/config/plugins/zenbones.lua new file mode 100644 index 0000000..0c6cf56 --- /dev/null +++ b/.config/nvim/lua/config/plugins/zenbones.lua @@ -0,0 +1,78 @@ +local M = { + "mcchrish/zenbones.nvim", + event = "VeryLazy", + dependencies = { + "rktjmp/lush.nvim", + }, +} + +function M.config() + vim.g.zenbones = { + style = "light", + lightness = "bright", + colorize_diagnostic_underline_text = true, + transparent_background = true, + } + + local lush = require("lush") + local base = require("zenbones") + + -- Create some specs + ---@diagnostic disable = undefined-global + local specs = lush.parse(function() + return { + CursorLine({ bg = "#f5f5f0" }), + Error({ fg = "#d9534f" }), + CursorLineNr({ fg = "#BCAAA4", bg = "#f5f5f0" }), + MsgArea({ fg = "#A1887F", bg = "#f1f1f1" }), + String({ fg = "#2E7D32", gui = "italic" }), + Comment({ fg = "#114499", gui = "bold,italic" }), + CopilotSuggestion({ fg = "#0066cc", gui = "bold,italic" }), + LineNr({ fg = "#9FA8AC", gui = "bold,italic" }), + LineNrAbove({ fg = "#9F080C", gui = "bold,italic" }), + Indent1({ fg = "#DFDF9A", gui = "italic" }), + Indent2({ fg = "#BAE1FF", gui = "italic" }), + Indent3({ fg = "#BAFFC9", gui = "italic" }), + Indent4({ fg = "#FFB3BA", gui = "italic" }), + Indent5({ fg = "#FFDFBA", gui = "italic" }), + Indent6({ fg = "#F3E5F5", gui = "italic" }), + NormalFloat({ bg = "#FFF9C4" }), + FloatBorder({ fg = "#FFB74D", bg = "#FFF9C4" }), + TelescopeNormal({ bg = "#EFEBE9" }), + TelescopeBorder({ fg = "#A1887F", bg = "#EFEBE9" }), + TelescopeSelection({ fg = "#FFFFFF", bg = "#1976D2" }), + DiagnosticSignError({ fg = "#ff2200", bg = "#fff5ff", gui = "bold" }), + DiagnosticVirtualTextInfo({ fg = "#0033bb", bg = "#f7fcff", gui = "bold,italic" }), + DiagnosticVirtualTextWarn({ fg = "#bb2200", bg = "#fff9f3", gui = "bold,italic" }), + DiagnosticVirtualTextError({ fg = "#ff2200", bg = "#fff5f3", gui = "italic" }), + DiagnosticUnderlineError({ fg = "#ff0000", gui = "undercurl" }), + DiagnosticUnderlineWarn({ fg = "#ff7700", gui = "undercurl" }), + DiagnosticUnderlineInfo({ fg = "#3366cc", gui = "undercurl" }), + MarkSignHL({ fg = "#009688", bg = "#E0F7FA" }), + MarkSignNumHL({ fg = "#B2DFDB", bg = "#E0F7FA" }), + GitSignsAdd({ fg = "#81C784" }), + GitSignsAddNr({ fg = "#C8E6C9" }), + GitSignsDelete({ fg = "#E53935" }), + GitSignsDeleteNr({ fg = "#FFCDD2" }), + GitSignsChange({ fg = "#FFA726" }), + GitSignsChangeNr({ fg = "#FFE0B2" }), + + PMenu({ bg = "#F7F5F0" }), + PMenuBorder({ bg = "#F7F5F0", fg = "#886622" }), + PMenuSel({ fg = "#FFFFFF", bg = "#1976D2" }), + PMenuSbar({ bg = "#90CAF9" }), + PMenuThumb({ bg = "#64B5F6" }), + StatusLine({ base = base.VertSplit, fg = "#BCAAA4" }), + StatusLineNC({ base = base.VertSplit, fg = "#BCAAA4" }), + + TreesitterContext({ bg = "#f0f0f0", fg = "#BCAAA4", gui = "bold,italic" }), + TreesitterContextLineNumber({ bg = "#f0f0f0", fg = "#979770", gui = "bold,italic" }), + } + end) + + -- Apply specs using lush tool-chain + vim.cmd("colorscheme zenbones") + lush.apply(lush.compile(specs)) +end + +return M diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua deleted file mode 100644 index 0d253c5..0000000 --- a/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,279 +0,0 @@ -return require("packer").startup(function() - use("hashivim/vim-terraform") - use("pierreglaser/folding-nvim") - use("tjdevries/colorbuddy.vim") - use("wbthomason/packer.nvim") - use("jose-elias-alvarez/nvim-lsp-ts-utils") - use("rafamadriz/friendly-snippets") - use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } }) - use({ "ray-x/guihua.lua", run = "cd lua/fzy && make" }) - use("jjo/vim-cue") - use("ckipp01/stylua-nvim") - - use({ - "theHamsta/nvim-dap-virtual-text", - config = function() - require("nvim-dap-virtual-text").setup({ - commented = true, - }) - end, - }) - - use({ - "jose-elias-alvarez/null-ls.nvim", - requires = { "nvim-lua/plenary.nvim" }, - config = function() - require("plugins/null-ls") - end, - }) - - use({ - "folke/yanky.nvim", - config = function() - require("plugins/yanky") - end, - }) - - use({ - "b3nj5m1n/kommentary", - config = function() - require("kommentary.config").use_extended_mappings() - vim.api.nvim_set_keymap("n", "", "kommentary_line_default", {}) -- C-/ - vim.api.nvim_set_keymap("v", "", "kommentary_visual_default", {}) -- C-/ - - require("kommentary.config").configure_language("default", { - prefer_single_line_comments = true, - }) - end, - }) - - use({ - "L3MON4D3/LuaSnip", - config = function() - require("luasnip/loaders/from_vscode").lazy_load() - end, - }) - - -- cmp - use({ - "hrsh7th/nvim-cmp", - requires = { - "andersevenrud/cmp-tmux", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-nvim-lsp-signature-help", - "L3MON4D3/LuaSnip", - "saadparwaiz1/cmp_luasnip", - }, - config = function() - require("plugins/nvim-cmp") - end, - }) - - use({ - "lewis6991/gitsigns.nvim", - requires = { - "nvim-lua/plenary.nvim", - }, - config = function() - require("gitsigns").setup({ - numhl = true, - 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", - }, - }, - }) - end, - }) - - use({ - "lukas-reineke/indent-blankline.nvim", - branch = "master", - config = function() - -- vim.wo.colorcolumn = "100" - vim.g.indent_blankline_char = "│" - vim.g.indent_blankline_space_char = "⬝" - vim.g.indent_blankline_space_char_highlight_list = { "IndentSpace" } - -- vim.g.indent_blankline_char_list = {'|', '¦', '┆', '┊'} - vim.g.indent_blankline_buftype_exclude = { "help", "terminal" } - vim.g.indent_blankline_filetype_exclude = { "text", "markdown" } - -- vim.g.indent_blankline_show_end_of_line = true - vim.g.indent_blankline_show_first_indent_level = true - vim.g.indent_blankline_show_trailing_blankline_indent = true - vim.g.indent_blankline_char_highlight_list = - { "Indent1", "Indent2", "Indent3", "Indent4", "Indent5", "Indent6" } - end, - }) - - use({ - "neovim/nvim-lspconfig", - config = function() - require("plugins/lsp-config") - end, - }) - - use({ - "nvim-telescope/telescope.nvim", - requires = { - "nvim-lua/popup.nvim", - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope-fzy-native.nvim", - "nvim-telescope/telescope-github.nvim", - "nvim-telescope/telescope-dap.nvim", - }, - config = function() - require("plugins/telescope") - end, - }) - - -- treesitter - use({ - "nvim-treesitter/nvim-treesitter", - requires = { - "nvim-treesitter/playground", - "nvim-treesitter/nvim-treesitter-textobjects", - "windwp/nvim-ts-autotag", - }, - run = ":TSUpdate", - config = function() - require("plugins/treesitter") - end, - }) - - use({ - "ray-x/go.nvim", - config = function() - require("go").setup({ - comment_placeholder = "", - icons = { breakpoint = "🧘", currentpos = "🏃" }, - dap_debug_gui = false, - }) - vim.cmd("autocmd FileType go nmap c :lua require('go.comment').gen()") - vim.cmd("autocmd BufWritePre *.go :silent! lua require('go.format').gofmt()") - vim.cmd("autocmd BufWritePre (InsertLeave?) lua vim.lsp.buf.formatting_sync(nil,500)") - end, - }) - - use({ - "nvim-treesitter/nvim-treesitter-context", - requires = { - "nvim-treesitter/nvim-treesitter", - }, - config = function() - require("plugins/treesitter-context") - end, - }) - - use({ - "onsails/lspkind-nvim", - config = function() - require("lspkind").init({}) - end, - }) - - use({ - "ojroques/nvim-osc52", - config = function() - require("plugins/osc52") - end, - }) - - -- marks - use({ - "chentoast/marks.nvim", - config = function() - require("plugins/marks") - end, - }) - - -- dap - use({ - "mfussenegger/nvim-dap", - config = function() - require("plugins/dap") - end, - }) - - -- go - use({ - "leoluz/nvim-dap-go", - config = function() - require("plugins/nvim-dap-go") - end, - }) - - -- lualine - use({ - "nvim-lualine/lualine.nvim", - requires = { "kyazdani42/nvim-web-devicons", opt = true }, - config = function() - require("plugins/lualine") - end, - }) - - -- lsp_lines - use({ - "https://git.sr.ht/~whynothugo/lsp_lines.nvim", - config = function() - require("lsp_lines").setup() - vim.diagnostic.config({ - virtual_text = false, - }) - end, - }) - - -- zenbones - use({ - "mcchrish/zenbones.nvim", - requires = { - "rktjmp/lush.nvim", - }, - config = function() - require("plugins/zenbones") - end, - }) - - -- copilot - use({ - "zbirenbaum/copilot.lua", - event = "VimEnter", - config = function() - vim.defer_fn(function() - require("plugins/copilot") - end, 100) - end, - }) - - use({ - "zbirenbaum/copilot-cmp", - after = { "copilot.lua" }, - config = function() - require("copilot_cmp").setup() - end, - }) -end) diff --git a/.config/nvim/lua/plugins/copilot.lua b/.config/nvim/lua/plugins/copilot.lua deleted file mode 100644 index b8bd8b5..0000000 --- a/.config/nvim/lua/plugins/copilot.lua +++ /dev/null @@ -1,39 +0,0 @@ -local copilot = require("copilot") - -copilot.setup({ - panel = { - enabled = true, - auto_refresh = false, - keymap = { - jump_prev = "[[", - jump_next = "]]", - accept = "", - refresh = "gr", - open = "", - }, - }, - suggestion = { - enabled = true, - auto_trigger = true, - debounce = 75, - keymap = { - accept = "", - next = "", - prev = "", - dismiss = "", - }, - }, - filetypes = { - yaml = false, - markdown = false, - help = false, - gitcommit = false, - gitrebase = false, - hgcommit = false, - svn = false, - cvs = false, - ["."] = false, - }, - copilot_node_command = "node", -- Node version must be < 18 - server_opts_overrides = {}, -}) diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua deleted file mode 100644 index eeb109f..0000000 --- a/.config/nvim/lua/plugins/dap.lua +++ /dev/null @@ -1,13 +0,0 @@ -require("dap") -local silent = { silent = true } - -vim.fn.sign_define("DapStopped", { text = "⇒", texthl = "", linehl = "debugPC", numhl = "" }) -vim.fn.sign_define("DapBreakpoint", { text = "🧘", texthl = "", linehl = "debugPC", numhl = "" }) - -vim.keymap.set("n", "DD", ":lua require 'dap'.toggle_breakpoint()", silent) -vim.keymap.set("n", "Dc", ":lua require 'dap'.continue()", silent) -vim.keymap.set("n", "Di", ":lua require 'dap'.step_into()", silent) -vim.keymap.set("n", "Do", ":lua require 'dap'.step_over()", silent) -vim.keymap.set("n", "DO", ":lua require 'dap'.step_out()", silent) -vim.keymap.set("n", "Dr", ":lua require 'dap'.repl.toggle({height = 5})", silent) -vim.keymap.set("n", "Dh", ":lua require 'dap.ui.widgets'.hover()", silent) diff --git a/.config/nvim/lua/plugins/lsp-config.lua b/.config/nvim/lua/plugins/lsp-config.lua deleted file mode 100644 index b797ad3..0000000 --- a/.config/nvim/lua/plugins/lsp-config.lua +++ /dev/null @@ -1,229 +0,0 @@ -local lspconfig = require("lspconfig") - -local capabilities = require("cmp_nvim_lsp").default_capabilities() - -vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()") -vim.keymap.set("i", "", "lua vim.lsp.buf.signature_help()") -vim.keymap.set("n", "1gd", "lua vim.lsp.buf.type_definition()") -vim.keymap.set("n", "gf", "lua vim.lsp.buf.format()") -vim.keymap.set("n", "rn", "lua vim.lsp.buf.rename()") -vim.keymap.set("n", "[d", "lua vim.lsp.diagnostic.goto_prev()") -vim.keymap.set("n", "]d", "lua vim.lsp.diagnostic.goto_next()") -vim.keymap.set("n", "gwa", "lua vim.lsp.buf.add_workspace_folder()") -vim.keymap.set("n", "gwr", "lua vim.lsp.buf.add_workspace_folder()") -vim.keymap.set("n", "gwl", "lua vim.lsp.buf.add_workspace_folder()") - -vim.cmd([[autocmd BufWritePre * lua vim.lsp.buf.format({sync = true})]]) - -local border = { - { "🭽", "FloatBorder" }, - { "▔", "FloatBorder" }, - { "🭾", "FloatBorder" }, - { "▕", "FloatBorder" }, - { "🭿", "FloatBorder" }, - { "▁", "FloatBorder" }, - { "🭼", "FloatBorder" }, - { "▏", "FloatBorder" }, -} - -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }) -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - update_in_insert = false, - virtual_text = false, -}) - -local signs = { Error = "🔥", Warn = "⚠️ ", Hint = "💡", Info = "💡" } -for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) -end - -local on_attach = function() - require("folding").on_attach() -end - --- simple setups -- -local servers = { - "bashls", - "dockerls", - "gopls", - "jsonls", - -- "sql", - "pyright", - "sumneko_lua", - "terraformls", - "yamlls", -} - -for _, lsp in ipairs(servers) do - lspconfig[lsp].setup({ on_attach = on_attach }) -end - -local efm_prettier = { - formatCommand = "prettier --stdin-filepath ${INPUT}", - formatStdin = true, -} - -lspconfig.gopls.setup({ - on_attach = on_attach, - settings = { - gopls = { - directoryFilters = { - "-bazel-bin", - "-bazel-out", - "-bazel-testlogs", - "-proto", - }, - }, - }, -}) - -lspconfig.sumneko_lua.setup({ - on_attach = function() - on_attach() - vim.cmd([[autocmd BufWritePre lua require'stylua-nvim'.format_file()]]) - end, - settings = { - Lua = { - completion = { kewordSnippet = "Disable" }, - diagnostics = { - enable = true, - globals = { "renoise", "use", "vim" }, - }, - runtime = { - version = "LuaJIT", - path = { "?.lua", "?/init.lua", "?/?.lua" }, - }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - maxPreload = 2000, - preloadFileSize = 1000, - checkThirdParty = false, - }, - }, - }, -}) - -lspconfig.terraformls.setup({}) - -local yaml_is_k8s = function(bufnr) - local lines = vim.api.nvim_buf_get_lines(bufnr, 0, 50, false) -- Stop after the first 50 lines - for _, l in pairs(lines) do - if string.find(l, "apiVersion") ~= nil then - return true - end - end - return false -end - -lspconfig.cssls.setup({ - cmd = { "vscode-css-languageserver", "--stdio" }, - capabilities = capabilities, -}) - -lspconfig.cssmodules_ls.setup({}) - -lspconfig.html.setup({ - cmd = { "vscode-html-languageserver", "--stdio" }, - filetypes = { "html" }, - init_options = { - configurationSection = { "html", "css", "javascript" }, - embeddedLanguages = { - css = true, - javascript = true, - }, - }, - settings = {}, -}) - -lspconfig.yamlls.setup({ - settings = { - yaml = { - format = { enable = true, singleQuote = true }, - schemaStore = { enable = true, url = "https://json.schemastore.org" }, - schemas = { - -- ["https://json.schemastore.org/github-workflow"] = "*.github/workflows/*", - ["https://json.schemastore.org/kustomization.json"] = "kustomization.yaml", - -- ["https://json.schemastore.org/ansible-role-2.9.json"] = "*/tasks/*.y*ml", - kubernetes = { - "clusterrolebinding.yaml", - "clusterrole-contour.yaml", - "clusterrole.yaml", - "configmap.yaml", - "cronjob.yaml", - "daemonset.yaml", - "deployment-*.yaml", - "deployment.yaml", - "*-deployment.yaml", - "hpa.yaml", - "ingress.yaml", - "job.yaml", - "namespace.yaml", - "pvc.yaml", - "rbac.yaml", - "rolebinding.yaml", - "role.yaml", - "sa.yaml", - "secret.yaml", - "serviceaccounts.yaml", - "service-account.yaml", - "serviceaccount.yaml", - "service-*.yaml", - "service.yaml", - "*-service.yaml", - "statefulset.yaml", - }, - }, - - validate = true, - }, - }, -}) - -require("lspconfig").tsserver.setup({}) - --- npm install -g typescript typescript-language-server --- require("lspconfig").tsserver.setup({ --- on_attach = function(client, bufnr) --- client.resolved_capabilities.document_formatting = false --- on_attach(client) - --- local ts_utils = require("nvim-lsp-ts-utils") - --- ts_utils.setup({ --- debug = false, --- disable_commands = false, --- enable_import_on_completion = false, --- import_all_timeout = 5000, -- ms - --- -- eslint --- eslint_enable_code_actions = true, --- eslint_enable_disable_comments = true, --- eslint_bin = "eslint_d", --- eslint_config_fallback = nil, --- eslint_enable_diagnostics = true, - --- -- formatting --- enable_formatting = true, --- formatter = "prettier", --- formatter_config_fallback = nil, - --- -- parentheses completion --- complete_parens = false, --- signature_help_in_parens = false, - --- -- update imports on file move --- update_imports_on_move = true, --- require_confirmation_on_move = true, --- watch_dir = nil, --- }) - --- ts_utils.setup_client(client) - --- vim.api.nvim_buf_set_keymap(bufnr, "n", "co", ":TSLspOrganize", { silent = true }) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent", { silent = true }) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "cR", ":TSLspRenameFile", { silent = true }) --- vim.api.nvim_buf_set_keymap(bufnr, "n", "ci", ":TSLspImportAll", { silent = true }) --- end, --- }) diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua deleted file mode 100644 index b470186..0000000 --- a/.config/nvim/lua/plugins/lualine.lua +++ /dev/null @@ -1,26 +0,0 @@ -local lualine = require("lualine") - -local function clock() - return os.date("%H:%M") -end - -lualine.setup({ - options = { - globalstatus = true, - theme = "onelight", - component_separators = { left = "╲", right = "╱" }, - section_separators = { left = "", right = "" }, - }, - sections = { - lualine_c = { - { - "filename", - path = 1, - file_status = true, - }, - }, - lualine_x = { "filetype" }, - lualine_y = { "location", "progress" }, - lualine_z = { clock }, - }, -}) diff --git a/.config/nvim/lua/plugins/marks.lua b/.config/nvim/lua/plugins/marks.lua deleted file mode 100644 index 4804627..0000000 --- a/.config/nvim/lua/plugins/marks.lua +++ /dev/null @@ -1,28 +0,0 @@ -local marks = require("marks") -marks.setup{ - - default_mappings = true, - -- which builtin marks to show. default {} - -- builtin_marks = { ".", "<", ">", "^" }, - - cyclic = true, - force_write_shada = false, - - -- marks, and bookmarks. - -- can be either a table with all/none of the keys, or a single number, in which case - -- the priority applies to all marks. - -- default 10. - -- sign_priority = { lower=10, upper=15, builtin=8, bookmark=20 }, - -- - -- disables mark tracking for specific filetypes. default {} - excluded_filetypes = {}, - - -- marks.nvim allows you to configure up to 10 bookmark groups, each with its own - -- sign/virttext. Bookmarks can be used to group together positions and quickly move - -- across multiple buffers. default sign is '!@#$%^&*()' (from 0 to 9), and - -- default virt_text is "". - bookmark_1 = { - sign = "⚑", - virt_text = "" - }, -} diff --git a/.config/nvim/lua/plugins/null-ls.lua b/.config/nvim/lua/plugins/null-ls.lua deleted file mode 100644 index 4567d22..0000000 --- a/.config/nvim/lua/plugins/null-ls.lua +++ /dev/null @@ -1,26 +0,0 @@ -local null_ls = require("null-ls") -local builtins = require("null-ls.builtins") - -null_ls.setup({ - sources = { - builtins.formatting.black, - builtins.formatting.buf, - builtins.formatting.cue_fmt, - builtins.formatting.shfmt, - builtins.formatting.buildifier, - builtins.completion.spell, - builtins.diagnostics.buf.with({ - args = { "lint", "--disable-symlinks", "--path", "$FILENAME" }, - cwd = function() - local file_dir = vim.fn.expand("%:p:h") .. ";" - local buf_yaml = vim.fn.findfile("buf.yaml", file_dir) - if buf_yaml then - return vim.fn.fnamemodify(buf_yaml, ":h") - end - end, - }), - builtins.diagnostics.buildifier, - builtins.diagnostics.cue_fmt, - }, - debug = true, -}) diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua deleted file mode 100644 index d9d6d7e..0000000 --- a/.config/nvim/lua/plugins/nvim-cmp.lua +++ /dev/null @@ -1,90 +0,0 @@ -local cmp = require("cmp") -local luasnip = require("luasnip") - -local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil -end - -cmp.setup({ - formatting = { - format = require("lspkind").cmp_format({ - with_text = true, - menu = { - buffer = "[Buffer]", - tmux = "[Tmux]", - luasnip = "[LuaSnip]", - nvim_lsp = "[LSP]", - nvim_lua = "[Lua]", - path = "[Path]", - }, - }), - }, - - window = { - completion = cmp.config.window.bordered({ - winhighlight = "Normal:PMenu,FloatBorder:PMenuBorder,CursorLine:PMenuSel,Search:None", - }), - documentation = cmp.config.window.bordered({ - winhighlight = "Normal:PMenu,FloatBorder:PMenu,CursorLine:PMenuSel,Search:None", - }), - }, - - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - - mapping = { - [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [""] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }, - - sources = cmp.config.sources({ - { name = "buffer", priority = 1 }, - { name = "luasnip", priority = 4 }, - { name = "copilot", group_index = 5 }, - { - name = "tmux", - priority = 2, - option = { - all_panes = true, - trigger_characters = {}, - }, - }, - { name = "nvim_lsp", priority = 3 }, - { name = "nvim_lsp_signature_help", priority = 4 }, - }), -}) diff --git a/.config/nvim/lua/plugins/nvim-dap-go.lua b/.config/nvim/lua/plugins/nvim-dap-go.lua deleted file mode 100644 index 20807d9..0000000 --- a/.config/nvim/lua/plugins/nvim-dap-go.lua +++ /dev/null @@ -1,5 +0,0 @@ -local dapgo = require("dap-go") -local silent = { silent = true } - -dapgo.setup() -vim.keymap.set("n", "y", ":lua require('dap-go').debug_test()", silent) diff --git a/.config/nvim/lua/plugins/osc52.lua b/.config/nvim/lua/plugins/osc52.lua deleted file mode 100644 index 620b41b..0000000 --- a/.config/nvim/lua/plugins/osc52.lua +++ /dev/null @@ -1,10 +0,0 @@ -local osc52 = require("osc52") -osc52.setup({ - max_length = 0, -- Maximum length of selection (0 for no limit) - silent = false, -- Disable message on successful copy - trim = false, -- Trim text before copy -}) - -vim.keymap.set("n", "c", require("osc52").copy_operator, { expr = true }) -vim.keymap.set("n", "cc", "c_", { remap = true }) -vim.keymap.set("x", "c", require("osc52").copy_visual) diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua deleted file mode 100644 index 4955d08..0000000 --- a/.config/nvim/lua/plugins/telescope.lua +++ /dev/null @@ -1,83 +0,0 @@ -local telescope = require("telescope") -local actions = require("telescope.actions") -local previewers = require("telescope.previewers") - -vim.keymap.set("n", "b", 'lua require("telescope.builtin").buffers()') -vim.keymap.set("n", "f", 'lua require("telescope.builtin").oldfiles()') -vim.keymap.set("n", "", 'lua require("telescope.builtin").oldfiles()') -vim.keymap.set("n", "d", 'lua require("telescope.builtin").diagnostics()') -vim.keymap.set("n", "e", 'lua require("telescope.builtin").git_files()') -vim.keymap.set("n", "g", 'lua require("telescope.builtin").git_status()') -vim.keymap.set("n", "a", 'lua require("telescope.builtin").lsp_code_actions()') -vim.keymap.set("n", "m", 'lua require("telescope.builtin").marks()') -vim.keymap.set("n", "s", 'lua require("telescope.builtin").lsp_document_symbols()') -vim.keymap.set("n", "t", 'lua require("telescope.builtin").treesitter()') -vim.keymap.set("n", "/", 'lua require("telescope.builtin").live_grep()') -vim.keymap.set("n", ".", 'lua require("telescope.builtin").file_browser()') -vim.keymap.set("n", "p", 'lua require("telescope.builtin").registers()') -vim.keymap.set("n", "gr", 'lua require("telescope.builtin").lsp_references()') -vim.keymap.set("n", "gd", 'lua require("telescope.builtin").lsp_definitions()') -vim.keymap.set("n", "g/", 'lua require("telescope.builtin").lsp_document_symbols()') -vim.keymap.set("n", "g?", 'lua require("telescope.builtin").lsp_workspace_symbols()') -vim.keymap.set("n", "ge", 'lua require("telescope.builtin").lsp_document_diagnostics()') -vim.keymap.set("n", "Db", 'lua require("telescope").extensions.dap.list_breakpoints()') -vim.keymap.set("n", "Dcc", 'lua require("telescope").extensions.dap.commands()') -vim.keymap.set("n", "Df", 'lua require("telescope").extensions.dap.frames()') -vim.keymap.set("n", "Dv", 'lua require("telescope").extensions.dap.variables()') - --- Setup -telescope.setup({ - defaults = { - layout_strategy = "flex", - -- layout_defaults = {flip_columns = 160}, - layout_config = { - preview_cutoff = 10, - }, - mappings = { - i = { - [""] = actions.select_default + actions.center, - [""] = actions.close, - [""] = actions.add_selection, - }, - }, - color_devicons = true, - file_previewer = previewers.vim_buffer_cat.new, - grep_previewer = previewers.vim_buffer_vimgrep.new, - qflist_previewer = previewers.vim_buffer_qflist.new, - }, -}) - -local layout_strategies = require("telescope.pickers.layout_strategies") -local config = require("telescope.config") - -layout_strategies.flex = function(self, max_columns, max_lines) - local layout_config = self.layout_config or {} - - local flip_columns = layout_config.flip_columns or 160 -- Here's why. - local flip_lines = layout_config.flip_lines or 20 - - if max_columns < flip_columns and max_lines > flip_lines then - self.layout_config = (config.values.layout_defaults or {})["vertical"] - return layout_strategies.vertical(self, max_columns, max_lines) - else - self.layout_config = (config.values.layout_defaults or {})["horizontal"] - return layout_strategies.horizontal(self, max_columns, max_lines) - end -end - --- Extensions -telescope.load_extension("dap") -telescope.load_extension("fzy_native") -telescope.load_extension("gh") --- telescope.load_extension("packer") -- currently breaking packer - -local M = {} - --- Pickers -M.project_files = function() - require("telescope.builtin").find_files({ - cwd = require("lspconfig.util").root_pattern(".git")(vim.fn.expand("%:p")), - }) -end - -return M diff --git a/.config/nvim/lua/plugins/treesitter-context.lua b/.config/nvim/lua/plugins/treesitter-context.lua deleted file mode 100644 index 37c0f7e..0000000 --- a/.config/nvim/lua/plugins/treesitter-context.lua +++ /dev/null @@ -1,37 +0,0 @@ -local config = require("treesitter-context") -config.setup({ - enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) - max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. - patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries. - -- For all filetypes - -- Note that setting an entry here replaces all other patterns for this entry. - -- By setting the 'default' entry below, you can control which nodes you want to - -- appear in the context window. - default = { - "class", - "function", - "method", - -- 'for', -- These won't appear in the context - -- 'while', - -- 'if', - -- 'switch', - -- 'case', - }, - -- Example for a specific filetype. - -- If a pattern is missing, *open a PR* so everyone can benefit. - -- rust = { - -- 'impl_item', - -- }, - }, - exact_patterns = { - -- Example for a specific filetype with Lua patterns - -- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will - -- exactly match "impl_item" only) - -- rust = true, - }, - - -- [!] The options below are exposed but shouldn't require your attention, - -- you can safely ignore them. - - zindex = 20, -- The Z-index of the context window -}) diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index 60a6002..0000000 --- a/.config/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,58 +0,0 @@ -vim.wo.foldmethod = "expr" -vim.wo.foldexpr = "nvim_treesitter#foldexpr()" - -require("nvim-treesitter.configs").setup { - ensure_installed = "all", - highlight = { - enable = true, - use_languagetree = true, - }, - - indent = { - enable = false - }, - - playground = { - enable = true, - disable = {}, - updatetime = 25, - persist_queries = false - }, - - incremental_selection = { - enable = true, - keymaps = { - init_selection = "ss", - node_incremental = "sq", - scope_incremental = "sd", - node_decremental = "sa", - }, - }, - - textobjects = { - move = { - enable = true, - goto_next_start = { - ["]]"] = "@function.outer", - ["]m"] = "@class.outer" - }, - goto_next_end = { - ["]["] = "@function.outer", - ["]M"] = "@class.outer" - }, - goto_previous_start = { - ["[["] = "@function.outer", - ["[m"] = "@class.outer" - }, - goto_previous_end = { - ["[]"] = "@function.outer", - ["[M"] = "@class.outer" - } - }, - }, - --- nvim-ts-autotag --- - autotag = { - enable = true, - filetypes = {"html", "javascriptreact", "xml"} - } -} diff --git a/.config/nvim/lua/plugins/yanky.lua b/.config/nvim/lua/plugins/yanky.lua deleted file mode 100644 index 12516f7..0000000 --- a/.config/nvim/lua/plugins/yanky.lua +++ /dev/null @@ -1,17 +0,0 @@ -local yanky = require("yanky") -yanky.setup({ - ring = { - history_length = 100, - storage = "memory", - sync_with_numbered_registers = false, - cancel_event = "update", - }, -}) - -vim.keymap.set({ "n", "x" }, "p", "(YankyPutAfter)") -vim.keymap.set({ "n", "x" }, "P", "(YankyPutBefore)") -vim.keymap.set({ "n", "x" }, "gp", "(YankyGPutAfter)") -vim.keymap.set({ "n", "x" }, "gP", "(YankyGPutBefore)") - -vim.keymap.set("n", "", "(YankyCycleForward)") -vim.keymap.set("n", "", "(YankyCycleBackward)") diff --git a/.config/nvim/lua/plugins/zenbones.lua b/.config/nvim/lua/plugins/zenbones.lua deleted file mode 100644 index 284131c..0000000 --- a/.config/nvim/lua/plugins/zenbones.lua +++ /dev/null @@ -1,67 +0,0 @@ -vim.g.zenbones = { - style = "light", - lightness = "bright", - colorize_diagnostic_underline_text = true, - transparent_background = true, - zenbones_compat = 1, -} - -local lush = require("lush") -local base = require("zenbones") - --- Create some specs ----@diagnostic disable = undefined-global -local specs = lush.parse(function() - return { - CursorLine({ bg = "#f5f5f0" }), - Error({ fg = "#d9534f" }), - CursorLineNr({ fg = "#BCAAA4", bg = "#f5f5f0" }), - MsgArea({ fg = "#A1887F", bg = "#f1f1f1" }), - String({ fg = "#2E7D32", gui = "italic" }), - Comment({ fg = "#114499", gui = "bold,italic" }), - CopilotSuggestion({ fg = "#0066cc", gui = "bold,italic" }), - LineNr({ fg = "#9FA8AC", gui = "bold,italic" }), - LineNrAbove({ fg = "#9F080C", gui = "bold,italic" }), - Indent1({ fg = "#DFDF9A", gui = "italic" }), - Indent2({ fg = "#BAE1FF", gui = "italic" }), - Indent3({ fg = "#BAFFC9", gui = "italic" }), - Indent4({ fg = "#FFB3BA", gui = "italic" }), - Indent5({ fg = "#FFDFBA", gui = "italic" }), - Indent6({ fg = "#F3E5F5", gui = "italic" }), - NormalFloat({ bg = "#FFF9C4" }), - FloatBorder({ fg = "#FFB74D", bg = "#FFF9C4" }), - TelescopeNormal({ bg = "#EFEBE9" }), - TelescopeBorder({ fg = "#A1887F", bg = "#EFEBE9" }), - TelescopeSelection({ fg = "#FFFFFF", bg = "#1976D2" }), - DiagnosticSignError({ fg = "#ff2200", bg = "#fff5ff", gui = "bold" }), - DiagnosticVirtualTextInfo({ fg = "#0033bb", bg = "#f7fcff", gui = "bold,italic" }), - DiagnosticVirtualTextWarn({ fg = "#bb2200", bg = "#fff9f3", gui = "bold,italic" }), - DiagnosticVirtualTextError({ fg = "#ff2200", bg = "#fff5f3", gui = "italic" }), - DiagnosticUnderlineError({ fg = "#ff0000", gui = "undercurl" }), - DiagnosticUnderlineWarn({ fg = "#ff7700", gui = "undercurl" }), - DiagnosticUnderlineInfo({ fg = "#3366cc", gui = "undercurl" }), - MarkSignHL({ fg = "#009688", bg = "#E0F7FA" }), - MarkSignNumHL({ fg = "#B2DFDB", bg = "#E0F7FA" }), - GitSignsAdd({ fg = "#81C784" }), - GitSignsAddNr({ fg = "#C8E6C9" }), - GitSignsDelete({ fg = "#E53935" }), - GitSignsDeleteNr({ fg = "#FFCDD2" }), - GitSignsChange({ fg = "#FFA726" }), - GitSignsChangeNr({ fg = "#FFE0B2" }), - - PMenu({ bg = "#F7F5F0" }), - PMenuBorder({ bg = "#F7F5F0", fg = "#886622" }), - PMenuSel({ fg = "#FFFFFF", bg = "#1976D2" }), - PMenuSbar({ bg = "#90CAF9" }), - PMenuThumb({ bg = "#64B5F6" }), - StatusLine({ base = base.VertSplit, fg = "#BCAAA4" }), - StatusLineNC({ base = base.VertSplit, fg = "#BCAAA4" }), - - TreesitterContext({ bg = "#f0f0f0", fg = "#BCAAA4", gui = "bold,italic" }), - TreesitterContextLineNumber({ bg = "#f0f0f0", fg = "#979770", gui = "bold,italic" }), - } -end) - --- Apply specs using lush tool-chain -vim.cmd("colorscheme zenbones") -lush.apply(lush.compile(specs)) diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 8c28ae0..40ee5f6 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -62,8 +62,8 @@ vim.o.cmdheight = 1 -- vim.o.title = true -- vim.o.titlestring = "%F%m %r %y" vim.o.fillchars = "stl: ,stlnc: " -vim.wo.foldmethod = "expr" -vim.wo.foldexpr = "nvim_treesitter#foldexpr()" +-- vim.wo.foldmethod = "expr" +-- vim.wo.foldexpr = "nvim_treesitter#foldexpr()" vim.g.netrw_dirhistmax = 0 --- Key mappings