summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorngharo <root@ngha.ro>2023-12-29 17:46:10 -0600
committerngharo <root@ngha.ro>2023-12-29 17:46:10 -0600
commit31474998d6935d48f678988c8a7a4fac7bb2ae72 (patch)
treec71114c23c31f888c0be1ec1b2efdab0d5ce6ca5
downloadnvim-31474998d6935d48f678988c8a7a4fac7bb2ae72.tar.xz
nvim-31474998d6935d48f678988c8a7a4fac7bb2ae72.zip
Inititial commit
-rw-r--r--after/plugin/colors.lua23
-rw-r--r--after/plugin/lsp.lua31
-rw-r--r--after/plugin/lualine.lua1
-rw-r--r--after/plugin/nvim-cmp.lua21
-rw-r--r--after/plugin/telescope.lua74
-rw-r--r--after/plugin/treesitter.lua41
-rw-r--r--init.lua3
-rw-r--r--lua/core/mappings.lua2
-rw-r--r--lua/core/options.lua19
-rw-r--r--lua/core/plugins.lua59
-rw-r--r--plugin/packer_compiled.lua165
11 files changed, 439 insertions, 0 deletions
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
+ ['<CR>'] = cmp.mapping.confirm({select = false}),
+
+ -- Ctrl+Space to trigger completion menu
+ ['<C-Space>'] = cmp.mapping.complete(),
+
+ -- Navigate between snippet placeholder
+ ['<C-f>'] = cmp_action.luasnip_jump_forward(),
+ ['<C-b>'] = cmp_action.luasnip_jump_backward(),
+
+ -- Scroll up and down in the completion documentation
+ ['<C-u>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-d>'] = 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', '<leader>b', builtin.buffers, 'Buffers')
+vks('n', '<leader>r', builtin.grep_string, 'References')
+vks('n', '<leader>p', project_files, 'Paths' )
+-- project_files unifies git_files and find_files
+-- vks('n', '<leader>sf', builtin.git_files, 'Git files')
+-- vks('n', '<leader>sp', builtin.find_files, 'Paths' )
+
+-- search submenu
+vks('n', '<leader>sc', builtin.commands, 'Commands')
+vks('n', '<leader>s:', builtin.command_history, 'Command history')
+vks('n', '<leader>sC', builtin.colorscheme, 'Colorchemes')
+vks('n', '<leader>ss', grep_string, 'String (like ag)') -- Emulate fzf's Ag:
+vks('n', '<leader>sb', builtin.buffers, 'Buffers')
+vks('n', '<leader>se', search_emoji, 'Emojis')
+vks('n', '<leader>sg', builtin.live_grep, 'Find/grep' )
+vks('n', '<leader>sh', builtin.help_tags, 'Help')
+vks('n', '<leader>sk', builtin.keymaps, 'Key mappings')
+vks('n', '<leader>so', builtin.oldfiles, 'Recent Opened files')
+vks('n', '<leader>sr', builtin.registers, 'Registers')
+vks('n', '<leader>sd', builtin.lsp_document_symbols, 'Symbols - document')
+vks('n', '<leader>sw', builtin.lsp_workspace_symbols, 'Symbols - workspace')
+vks('n', '<leader>st', builtin.tags, 'Tags')
+vks('n', '<leader>s?', builtin.resume, 'Resume previous search')
+
+-- vim.keymap.set('n', '<leader>/', 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,
+ },
+}
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..07ad4a0
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,3 @@
+require("core.options")
+require("core.mappings")
+require("core.plugins")
diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua
new file mode 100644
index 0000000..3640341
--- /dev/null
+++ b/lua/core/mappings.lua
@@ -0,0 +1,2 @@
+vim.g.mapleader = " " -- easy to reach leader key
+vim.keymap.set("n", "-", vim.cmd.Ex) -- need nvim 0.8+
diff --git a/lua/core/options.lua b/lua/core/options.lua
new file mode 100644
index 0000000..110c46a
--- /dev/null
+++ b/lua/core/options.lua
@@ -0,0 +1,19 @@
+vim.opt.tabstop = 2
+vim.opt.shiftwidth = 2
+vim.opt.shiftround = true -- round indent to sw compatible
+vim.opt.expandtab = true
+
+vim.opt.mouse = 'a'
+vim.opt.clipboard = 'unnamedplus'
+-- Case insensitive searching UNLESS /C or capital in search
+vim.opt.ignorecase = true
+vim.opt.smartcase = true
+
+-- Better editor UI
+vim.opt.number = true
+-- vim.opt.numberwidth = 3
+vim.opt.relativenumber = true
+-- vim.opt.signcolumn = 'yes:2'
+vim.opt.signcolumn = 'yes'
+vim.opt.cursorline = false
+vim.opt.listchars = 'trail:·,nbsp:◇,tab:→ ,extends:▸,precedes:◂,eol:⁋'
diff --git a/lua/core/plugins.lua b/lua/core/plugins.lua
new file mode 100644
index 0000000..7d8c3c1
--- /dev/null
+++ b/lua/core/plugins.lua
@@ -0,0 +1,59 @@
+local ensure_packer = function()
+ local fn = vim.fn
+ local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
+ if fn.empty(fn.glob(install_path)) > 0 then
+ fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
+ vim.cmd [[packadd packer.nvim]]
+ return true
+ end
+ return false
+end
+
+local packer_bootstrap = ensure_packer()
+
+return require('packer').startup(function(use)
+ use 'wbthomason/packer.nvim'
+
+ -- Telescope and deps
+ use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }
+ use 'nvim-telescope/telescope-symbols.nvim'
+ use {
+ 'nvim-telescope/telescope.nvim', tag = '0.1.5',
+ requires = { {'nvim-lua/plenary.nvim'} }
+ }
+
+ -- color scheme
+ use({ 'rose-pine/neovim', as = 'rose-pine' })
+
+ -- visual undo
+ use 'mbbill/undotree'
+
+ -- lsp
+ use {
+ 'VonHeikemen/lsp-zero.nvim',
+ branch = 'v3.x',
+ requires = {
+ --- Uncomment these if you want to manage LSP servers from neovim
+ -- {'williamboman/mason.nvim'},
+ -- {'williamboman/mason-lspconfig.nvim'},
+
+ -- LSP Support
+ {'neovim/nvim-lspconfig'},
+ -- Autocompletion
+ {'hrsh7th/nvim-cmp'},
+ {'hrsh7th/cmp-nvim-lsp'},
+ {'L3MON4D3/LuaSnip'},
+ }
+ }
+
+ use {
+ 'nvim-lualine/lualine.nvim',
+ requires = { 'nvim-tree/nvim-web-devicons', opt = true }
+ }
+
+ -- Automatically set up your configuration after cloning packer.nvim
+ -- Put this at the end after all plugins
+ if packer_bootstrap then
+ require('packer').sync()
+ end
+end)
diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua
new file mode 100644
index 0000000..1d91a26
--- /dev/null
+++ b/plugin/packer_compiled.lua
@@ -0,0 +1,165 @@
+-- Automatically generated packer.nvim plugin loader code
+
+if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
+ vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
+ return
+end
+
+vim.api.nvim_command('packadd packer.nvim')
+
+local no_errors, error_msg = pcall(function()
+
+_G._packer = _G._packer or {}
+_G._packer.inside_compile = true
+
+local time
+local profile_info
+local should_profile = false
+if should_profile then
+ local hrtime = vim.loop.hrtime
+ profile_info = {}
+ time = function(chunk, start)
+ if start then
+ profile_info[chunk] = hrtime()
+ else
+ profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
+ end
+ end
+else
+ time = function(chunk, start) end
+end
+
+local function save_profiles(threshold)
+ local sorted_times = {}
+ for chunk_name, time_taken in pairs(profile_info) do
+ sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
+ end
+ table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
+ local results = {}
+ for i, elem in ipairs(sorted_times) do
+ if not threshold or threshold and elem[2] > threshold then
+ results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
+ end
+ end
+ if threshold then
+ table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
+ end
+
+ _G._packer.profile_output = results
+end
+
+time([[Luarocks path setup]], true)
+local package_path_str = "/Users/ngharo/.cache/nvim/packer_hererocks/2.1.1700008891/share/lua/5.1/?.lua;/Users/ngharo/.cache/nvim/packer_hererocks/2.1.1700008891/share/lua/5.1/?/init.lua;/Users/ngharo/.cache/nvim/packer_hererocks/2.1.1700008891/lib/luarocks/rocks-5.1/?.lua;/Users/ngharo/.cache/nvim/packer_hererocks/2.1.1700008891/lib/luarocks/rocks-5.1/?/init.lua"
+local install_cpath_pattern = "/Users/ngharo/.cache/nvim/packer_hererocks/2.1.1700008891/lib/lua/5.1/?.so"
+if not string.find(package.path, package_path_str, 1, true) then
+ package.path = package.path .. ';' .. package_path_str
+end
+
+if not string.find(package.cpath, install_cpath_pattern, 1, true) then
+ package.cpath = package.cpath .. ';' .. install_cpath_pattern
+end
+
+time([[Luarocks path setup]], false)
+time([[try_loadstring definition]], true)
+local function try_loadstring(s, component, name)
+ local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
+ if not success then
+ vim.schedule(function()
+ vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
+ end)
+ end
+ return result
+end
+
+time([[try_loadstring definition]], false)
+time([[Defining packer_plugins]], true)
+_G.packer_plugins = {
+ LuaSnip = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/LuaSnip",
+ url = "https://github.com/L3MON4D3/LuaSnip"
+ },
+ ["cmp-nvim-lsp"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
+ url = "https://github.com/hrsh7th/cmp-nvim-lsp"
+ },
+ ["lsp-zero.nvim"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim",
+ url = "https://github.com/VonHeikemen/lsp-zero.nvim"
+ },
+ ["lualine.nvim"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/lualine.nvim",
+ url = "https://github.com/nvim-lualine/lualine.nvim"
+ },
+ ["nvim-cmp"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/nvim-cmp",
+ url = "https://github.com/hrsh7th/nvim-cmp"
+ },
+ ["nvim-lspconfig"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
+ url = "https://github.com/neovim/nvim-lspconfig"
+ },
+ ["nvim-treesitter"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
+ url = "https://github.com/nvim-treesitter/nvim-treesitter"
+ },
+ ["nvim-web-devicons"] = {
+ loaded = false,
+ needs_bufread = false,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons",
+ url = "https://github.com/nvim-tree/nvim-web-devicons"
+ },
+ ["packer.nvim"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/packer.nvim",
+ url = "https://github.com/wbthomason/packer.nvim"
+ },
+ ["plenary.nvim"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/plenary.nvim",
+ url = "https://github.com/nvim-lua/plenary.nvim"
+ },
+ ["rose-pine"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/rose-pine",
+ url = "https://github.com/rose-pine/neovim"
+ },
+ ["telescope-symbols.nvim"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/telescope-symbols.nvim",
+ url = "https://github.com/nvim-telescope/telescope-symbols.nvim"
+ },
+ ["telescope.nvim"] = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/telescope.nvim",
+ url = "https://github.com/nvim-telescope/telescope.nvim"
+ },
+ undotree = {
+ loaded = true,
+ path = "/Users/ngharo/.local/share/nvim/site/pack/packer/start/undotree",
+ url = "https://github.com/mbbill/undotree"
+ }
+}
+
+time([[Defining packer_plugins]], false)
+
+_G._packer.inside_compile = false
+if _G._packer.needs_bufread == true then
+ vim.cmd("doautocmd BufRead")
+end
+_G._packer.needs_bufread = false
+
+if should_profile then save_profiles() end
+
+end)
+
+if not no_errors then
+ error_msg = error_msg:gsub('"', '\\"')
+ vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
+end