From 31474998d6935d48f678988c8a7a4fac7bb2ae72 Mon Sep 17 00:00:00 2001 From: ngharo Date: Fri, 29 Dec 2023 17:46:10 -0600 Subject: Inititial commit --- after/plugin/colors.lua | 23 ++++++++++++++ after/plugin/lsp.lua | 31 +++++++++++++++++++ after/plugin/lualine.lua | 1 + after/plugin/nvim-cmp.lua | 21 +++++++++++++ after/plugin/telescope.lua | 74 +++++++++++++++++++++++++++++++++++++++++++++ after/plugin/treesitter.lua | 41 +++++++++++++++++++++++++ 6 files changed, 191 insertions(+) create mode 100644 after/plugin/colors.lua create mode 100644 after/plugin/lsp.lua create mode 100644 after/plugin/lualine.lua create mode 100644 after/plugin/nvim-cmp.lua create mode 100644 after/plugin/telescope.lua create mode 100644 after/plugin/treesitter.lua (limited to 'after') diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua new file mode 100644 index 0000000..2fc22d7 --- /dev/null +++ b/after/plugin/colors.lua @@ -0,0 +1,23 @@ +-- +-- COLORS -- +-- + +vim.opt.termguicolors = true + +local rp = require('rose-pine') +rp.setup({ + --- @usage 'auto'|'main'|'moon'|'dawn' + variant = 'auto', + disable_italics = true, +}) + +function SetColor(color) + color = color or "rose-pine" -- have a default value + vim.cmd.colorscheme(color) + + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) + vim.api.nvim_set_hl(0, "ColorColumn", { bg = "#330000" }) +end + +SetColor() -- run at startup diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..bf6a29d --- /dev/null +++ b/after/plugin/lsp.lua @@ -0,0 +1,31 @@ +local lsp_zero = require('lsp-zero') + +lsp_zero.on_attach(function(client, bufnr) + -- see :help lsp-zero-keybindings + -- to learn the available actions + lsp_zero.default_keymaps({buffer = bufnr}) +end) + + +local lspconfig = require('lspconfig') +lspconfig.gopls.setup{} +lspconfig.terraformls.setup{} +lspconfig.yamlls.setup { + settings = { + yaml = { + kubernetes = "*.{yaml,yml}", + ["http://json.schemastore.org/github-workflow"] = ".github/workflows/*", + ["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}", + ["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}", + ["http://json.schemastore.org/prettierrc"] = ".prettierrc.{yml,yaml}", + ["http://json.schemastore.org/kustomization"] = "kustomization.{yml,yaml}", + ["http://json.schemastore.org/ansible-playbook"] = "*play*.{yml,yaml}", + ["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}", + ["https://json.schemastore.org/dependabot-v2"] = ".github/dependabot.{yml,yaml}", + ["https://json.schemastore.org/gitlab-ci"] = "*gitlab-ci*.{yml,yaml}", + ["https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"] = "*api*.{yml,yaml}", + ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "*docker-compose*.{yml,yaml}", + ["https://raw.githubusercontent.com/argoproj/argo-workflows/master/api/jsonschema/schema.json"] = "*flow*.{yml,yaml}", + } + } +} diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua new file mode 100644 index 0000000..90e6db2 --- /dev/null +++ b/after/plugin/lualine.lua @@ -0,0 +1 @@ +require('lualine').setup() diff --git a/after/plugin/nvim-cmp.lua b/after/plugin/nvim-cmp.lua new file mode 100644 index 0000000..6548b71 --- /dev/null +++ b/after/plugin/nvim-cmp.lua @@ -0,0 +1,21 @@ +local cmp = require('cmp') +-- using lsp-zero +local cmp_action = require('lsp-zero').cmp_action() + +cmp.setup({ + mapping = cmp.mapping.preset.insert({ + -- `Enter` key to confirm completion + [''] = cmp.mapping.confirm({select = false}), + + -- Ctrl+Space to trigger completion menu + [''] = cmp.mapping.complete(), + + -- Navigate between snippet placeholder + [''] = cmp_action.luasnip_jump_forward(), + [''] = cmp_action.luasnip_jump_backward(), + + -- Scroll up and down in the completion documentation + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + }) +}) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua new file mode 100644 index 0000000..16187c6 --- /dev/null +++ b/after/plugin/telescope.lua @@ -0,0 +1,74 @@ +local builtin = require('telescope.builtin') +local Job = require("plenary.job") + +local vks = function(mode, key, action, desc) + vim.keymap.set(mode, key, action , { noremap = true, desc = desc }) +end + +local function search_emoji() + builtin.symbols({ sources = {'emoji'} }) +end + +local function grep_string() + builtin.grep_string({ search = "", only_sort_text = true }) +end + +-- borrowed from ThePrimeagen/harpoon/utils.lua +local function get_os_command_output(cmd, cwd) + if type(cmd) ~= "table" then + print("Harpoon: [get_os_command_output]: cmd has to be a table") + return {} + end + local command = table.remove(cmd, 1) + local stderr = {} + local stdout, ret = Job + :new({ + command = command, + args = cmd, + cwd = cwd, + on_stderr = function(_, data) + table.insert(stderr, data) + end, + }) + :sync() + return stdout, ret, stderr +end + +local function project_files() + local _, ret, _ = get_os_command_output({ + 'git', 'rev-parse', '--is-inside-wirk-tree', + }) + if ret == 0 then + builtin.git_files({ prompt_title = 'Git Files', prompt_prefix = '>>' }) + else + builtin.find_files() + end +end + +-- direct commands +vks('n', 'b', builtin.buffers, 'Buffers') +vks('n', 'r', builtin.grep_string, 'References') +vks('n', 'p', project_files, 'Paths' ) +-- project_files unifies git_files and find_files +-- vks('n', 'sf', builtin.git_files, 'Git files') +-- vks('n', 'sp', builtin.find_files, 'Paths' ) + +-- search submenu +vks('n', 'sc', builtin.commands, 'Commands') +vks('n', 's:', builtin.command_history, 'Command history') +vks('n', 'sC', builtin.colorscheme, 'Colorchemes') +vks('n', 'ss', grep_string, 'String (like ag)') -- Emulate fzf's Ag: +vks('n', 'sb', builtin.buffers, 'Buffers') +vks('n', 'se', search_emoji, 'Emojis') +vks('n', 'sg', builtin.live_grep, 'Find/grep' ) +vks('n', 'sh', builtin.help_tags, 'Help') +vks('n', 'sk', builtin.keymaps, 'Key mappings') +vks('n', 'so', builtin.oldfiles, 'Recent Opened files') +vks('n', 'sr', builtin.registers, 'Registers') +vks('n', 'sd', builtin.lsp_document_symbols, 'Symbols - document') +vks('n', 'sw', builtin.lsp_workspace_symbols, 'Symbols - workspace') +vks('n', 'st', builtin.tags, 'Tags') +vks('n', 's?', builtin.resume, 'Resume previous search') + +-- vim.keymap.set('n', '/', builtin.current_buffer_fuzzy_find, { desc = '[/] Fuzzily search in current buffer]' }) +-- E5108: Error executing lua: ...r/start/telescope.nvim/lua/telescope/builtin/__files.lua:413: attempt to call method '_get_hl_from_capture' (a nil value) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..8c13f8f --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,41 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "ruby", "python", "yaml", "go", "terraform" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + -- List of parsers to ignore installing (or "all") + -- ignore_install = { "javascript" }, + + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + + highlight = { + enable = true, + + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + disable = { "c", "rust" }, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} -- cgit v1.2.3