commit ecfa4a1774d26fa420d6cd0724f65bdbdedb46c6 Author: gnat Date: Tue Jul 30 10:06:43 2024 -0700 I should probably make this a git repo diff --git a/README.md b/README.md new file mode 100644 index 0000000..63ca63b --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# my neovim configuration +it works. diff --git a/colors.vim b/colors.vim new file mode 100644 index 0000000..6f2d0e3 --- /dev/null +++ b/colors.vim @@ -0,0 +1,19 @@ +set background=dark +colorscheme oxocarbon +hi MyNormalMode guibg=#33b1ff guifg=#161616 +hi MyInsertMode guibg=#42be65 guifg=#161616 +hi MyVisualMode guibg=#be95ff guifg=#161616 +hi MyDefaultMode guibg=#FF7EB6 guifg=#161616 +hi CustomErrorHl guifg=#FF7EB6 guibg=#161616 +hi CustomWarnHl guifg=#FFE97B guibg=#161616 +hi tabActive guibg=#FF7EB6 guifg=#161616 +hi tabInactive guibg=#3c3836 guifg=#dde1e6 +hi tabSepActive guibg=#262626 guifg=#FF7EB6 +hi tabSepActive2 guifg=#FF7EB6 guibg=#3c3836 +hi tabSepInactive guibg=#262626 guifg=#3c3836 +hi tabSepInactive2 guifg=#3c3836 guibg=#262626 +hi tabSepSpecial guifg=#FF7EB6 guibg=#262626 +hi tabSepSpecial2 guifg=#262626 guibg=#262626 +hi tabSepSpecial3 guifg=#262626 guibg=#262626 +luafile ~/.config/nvim/lua/core/statusline.lua +luafile ~/.config/nvim/lua/core/tabline.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..29256fc --- /dev/null +++ b/init.lua @@ -0,0 +1,16 @@ +require 'core.keys' +require 'core.lazy' +require 'core.opts' +vim.api.nvim_command("source ~/.config/nvim/colors.vim") +require 'core.statusline' +require 'core.tabline' +require 'core.diagnostics' + +local function set_terminal_title() + local filepath = vim.fn.expand("%:p") + local title = "vim - " .. filepath + vim.fn.system(string.format("printf '\27]2;%s\7'", title)) +end + +-- vim.cmd([[autocmd BufEnter * lua set_terminal_title()]]) + diff --git a/lua/core/diagnostics.lua b/lua/core/diagnostics.lua new file mode 100644 index 0000000..3336381 --- /dev/null +++ b/lua/core/diagnostics.lua @@ -0,0 +1,45 @@ +function capitalize_head_exclusive(str) + str = string.lower(str) + str = string.gsub(str, "^%l", string.upper) + return str +end + +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 max_width = math.min(math.floor(vim.o.columns * 0.7), 100) +local max_height = math.min(math.floor(vim.o.lines * 0.3), 30) + +vim.diagnostic.config({ + underline = true, + update_in_insert = true, + severity_sort = true, + virtual_text = false and { + spacing = 1, + prefix = '', -- TODO: in nvim-0.10.0 this can be a function, so format won't be necessary + format = function(d) + local level = vim.diagnostic.severity[d.severity] + return string.format('%s %s', signs[capitalize_head_exclusive(level)], d.message) + end, + }, + float = { + max_width = max_width, + max_height = max_height, + border = border_style, + title = { { '  ', 'DiagnosticFloatTitleIcon' }, { 'Problems ', 'DiagnosticFloatTitle' } }, + focusable = false, + scope = 'line', + source = 'if_many', + prefix = function(diag) + local level = vim.diagnostic.severity[diag.severity] + local prefix = string.format('%s ', signs[capitalize_head_exclusive(level)]) + return prefix, 'Diagnostic' .. level:gsub('^%l', string.upper) + end, + }, +}) + +vim.cmd [[ autocmd! CursorHold * lua vim.diagnostic.open_float()]] + diff --git a/lua/core/keys.lua b/lua/core/keys.lua new file mode 100644 index 0000000..4cd1c90 --- /dev/null +++ b/lua/core/keys.lua @@ -0,0 +1,89 @@ +vim.g.mapleader = " " +local opts = { noremap = true, silent = true } +local term_opts = { silent = true } + +local keymap = vim.keymap.set + +keymap('t', '', '', { noremap = true }) + +-- window navigation +keymap("n", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +-- window resizing +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + +-- buffer navigation +keymap("n", "", ":bnext", opts) +keymap("n", "", ":bprevious", opts) + +-- move selection up or down +keymap("n", "", ":m .+1==", opts) +keymap("n", "", ":m .-2==", opts) + +-- don't exit visual mode +keymap("v", "<", "", ">gv^", opts) + +-- Move text up and down +keymap("v", "", ":m '>+1gv=gv", opts) +keymap("v", "", ":m '<-2gv=gv", opts) +keymap("v", "p", '"_dP', opts) + +-- Move text up and down +keymap("x", "J", ":m '>+1gv=gv", opts) +keymap("x", "K", ":m '<-2gv=gv", opts) +keymap("x", "", ":m '>+1gv=gv", opts) +keymap("x", "", ":m '<-2gv=gv", opts) + +-- force me to use vim keys +keymap('n', '', '', opts) +keymap('n', '', '', opts) +keymap('n', '', '', opts) +keymap('n', '', '', opts) + +keymap('i', '', '', opts) +keymap('i', '', '', opts) +keymap('i', '', '', opts) +keymap('i', '', '', opts) + +keymap('i', '', '', opts) +keymap('i', '', '', opts) +keymap('i', '', '', opts) +keymap('i', '', '', opts) + +keymap('x', '', '', opts) +keymap('x', '', '', opts) +keymap('x', '', '', opts) +keymap('x', '', '', opts) + +-- split windows +keymap('n', 'v', ':vsplit', opts) +keymap('n', 'h', ':split', opts) + +keymap('n', '', ':nohlsearch', opts) + +keymap('n', 's', ':lua if vim.o.spell then vim.o.spell = false else vim.o.spell = true end', + { noremap = true, silent = true }) +keymap('n', 'c', ':ColorizerToggle', opts) + +-- Tabs +keymap('n', '', ':tabnew', opts) +keymap('n', '', ':tabclose', opts) +keymap('n', '', ':tabp', opts) +keymap('n', '', ':tabn', opts) + +-- Trouble.lua +keymap('n', 't', ':TroubleToggle', opts) + +-- lsp diagnostic movement +keymap('n', '>d', ':lua vim.diagnostic.goto_next()', opts) +keymap('n', '', opts) + +-- source init +keymap('n', 'ri', ':luafile ~/.config/nvim/init.lua', opts) -- ri: reload init diff --git a/lua/core/lazy.lua b/lua/core/lazy.lua new file mode 100644 index 0000000..e417fc2 --- /dev/null +++ b/lua/core/lazy.lua @@ -0,0 +1,17 @@ +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", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath, + }) +end + +vim.opt.rtp:prepend(lazypath) + +require('lazy').setup({ + import='plugins', +}) diff --git a/lua/core/opts.lua b/lua/core/opts.lua new file mode 100644 index 0000000..c2630ea --- /dev/null +++ b/lua/core/opts.lua @@ -0,0 +1,33 @@ +local opt = vim.opt + +opt.expandtab = true +opt.smarttab = true +opt.shiftwidth = 4 +opt.tabstop = 4 + +opt.hlsearch = true +opt.incsearch = true +opt.ignorecase = true +opt.smartcase = true + +opt.splitbelow = true +opt.splitright = true +opt.wrap = false +opt.scrolloff = 5 +opt.fileencoding = 'utf-8' +opt.termguicolors = true + +opt.relativenumber = true +opt.cursorline = true +opt.number = true + +opt.spelllang = { 'en_us' } +opt.background = 'light' + +opt.updatetime = 50 + +border_style = 'rounded' + +vim.cmd('set showtabline=2') +vim.cmd('colorscheme gruvbox') +vim.cmd('hi SpellBad gui=undercurl guifg=#cc241c') diff --git a/lua/core/statusline.lua b/lua/core/statusline.lua new file mode 100644 index 0000000..394ebf9 --- /dev/null +++ b/lua/core/statusline.lua @@ -0,0 +1,123 @@ +function get_mode_highlight(mode) + local mode_highlights = { + n = "%#MyNormalMode#", + i = "%#MyInsertMode#", + t = "%#MyInsertMode#", + v = "%#MyVisualMode#", + V = "%#MyVisualMode#", + [""] = "%#MyVisualMode#", + c = "%#MyDefaultMode#", + s = "%#MyDefaultMode#", + S = "%#MyDefaultMode#", + [""] = "%#MyDefaultMode#", + R = "%#MyDefaultMode#", + Rv = "%#yDefaultMode#", + } + + return mode_highlights[mode] or "MyDefaultMode" +end + +function get_mode_name(mode) + local mode_map = { + n = "Normal", + i = "Insert", + t = "Terminal", + v = "Visual", + V = "V-Line", + [""] = "V-Block", + c = "Command", + s = "Select", + S = "S-Line", + [""] = "S-Block", + R = "Replace", + Rv = "V-Replace", + } + return mode_map[mode] +end + +function format_filename() + return vim.fn.expand('%:t') ~= '' and vim.fn.expand('%:t') or 'nil' +end + +function get_line_chars() + return string.format('%s:%s', vim.fn.col('.')-1, vim.fn.col('$')-1) +end + +function get_diagnostic_count() + local bufnr = vim.api.nvim_get_current_buf() + local diagnostics = vim.diagnostic.get(bufnr) + + local warning_count = 0 + local error_count = 0 + + for _, diagnostic in ipairs(diagnostics) do + if diagnostic.severity == vim.lsp.protocol.DiagnosticSeverity.Warning then + warning_count = warning_count + 1 + elseif diagnostic.severity == vim.lsp.protocol.DiagnosticSeverity.Error then + error_count = error_count + 1 + end + end + + if warning_count + error_count == 0 then + return '' + elseif error_count == 0 then + return '[%#CustomWarnHl#' .. ' ' .. warning_count .. '%*]' + elseif warning_count == 0 then + return "[%#CustomErrorHl# " .. error_count .. '%*]' + end + return "[%#CustomErrorHl# " .. error_count .. '%*] [%#CustomWarnHl#' .. ' ' .. warning_count .. '%*]' +end + +function get_buffer_perms() + local readable = vim.loop.fs_access(vim.fn.expand('%'), 'R') + local writable = vim.loop.fs_access(vim.fn.expand('%'), 'W') + local executable = vim.loop.fs_access(vim.fn.expand('%'), 'X') + + local permissions = "" + if readable then + permissions = permissions .. "r" + end + if writable then + permissions = permissions .. "w" + end + if executable then + permissions = permissions .. "x" + end + + return permissions +end + +local function statusline() + local file_name = " %f" + local modified = "%m" + local align_right = "%=" + local fileencoding = " %{&fileencoding?&fileencoding:&encoding}" + local filetype = " %y" + local percentage = "(%p%%)" + local linecol = "[%l:%L][%{luaeval('get_line_chars()')}]" + local perms = ' %{luaeval("get_buffer_perms()")}' + local diagnostics = ' %{% luaeval("get_diagnostic_count()")%}' + + local mode_name = '%{luaeval("get_mode_name(vim.fn.mode())")}' + local buffer = " %{luaeval('format_filename()')}" -- vim.fn.expand('%:t') ~= '' and vim.fn.expand('%:t') or 'nil' + local mode_highlight = '%{%(luaeval("get_mode_highlight(vim.fn.mode())"))%}' + local rm_highlight = '%*' + + return string.format( + "%s [%s] %s%s%s%s%s%s%s%s%s ", + mode_highlight, + mode_name, + rm_highlight, + buffer, + modified, + linecol, + percentage, + diagnostics, + align_right, + filetype, + fileencoding, + perms + ) +end + +vim.opt.statusline = statusline() diff --git a/lua/core/tabline.lua b/lua/core/tabline.lua new file mode 100644 index 0000000..1a0816d --- /dev/null +++ b/lua/core/tabline.lua @@ -0,0 +1,23 @@ +function custom_tabline() + local current_tab = vim.fn.tabpagenr() + local tabline = '' + for t = 1, vim.fn.tabpagenr('$') do + local win_count = vim.fn.tabpagewinnr(t, '$') + local buflist = vim.fn.tabpagebuflist(t) + local bufnr = buflist[1] + + tabline = tabline .. (t == current_tab and '%#tabSepInactive2#' or '%#tabSepInactive2#') + tabline = tabline .. (t == current_tab and '%#tabSepSpecial#' or '') + tabline = tabline .. (t == current_tab and '%#tabActive#' or '%#tabInactive#') + tabline = tabline .. ' ' .. (t-1)..': ' + --tabline = tabline .. ' ' + tabline = tabline .. ' ' .. vim.fn.fnamemodify(vim.fn.bufname(bufnr), ':t') .. ' ' + tabline = tabline .. ' ' + tabline = tabline .. (t == current_tab and '%#tabSepActive#' or '%#tabSepInactive#') + tabline = tabline .. '%*' + end + return tabline .. '%*' +end + +-- vim.o.tabline = '%{%luaeval("custom_tabline()")%}' + diff --git a/lua/plugins/auto-pairs.lua b/lua/plugins/auto-pairs.lua new file mode 100644 index 0000000..97e2c68 --- /dev/null +++ b/lua/plugins/auto-pairs.lua @@ -0,0 +1 @@ +return {} -- return {'jiangmiao/auto-pairs'} diff --git a/lua/plugins/barbecue.lua b/lua/plugins/barbecue.lua new file mode 100644 index 0000000..aa84da8 --- /dev/null +++ b/lua/plugins/barbecue.lua @@ -0,0 +1,11 @@ +return { + "utilyre/barbecue.nvim", + name = "barbecue", + version = "*", + event = { 'LspAttach' }, + dependencies = { + "SmiteshP/nvim-navic", + "nvim-tree/nvim-web-devicons", -- optional dependency + }, + opts = {} +} diff --git a/lua/plugins/biscuit.lua b/lua/plugins/biscuit.lua new file mode 100644 index 0000000..5912d26 --- /dev/null +++ b/lua/plugins/biscuit.lua @@ -0,0 +1 @@ +return { 'Biscuit-Colorscheme/nvim', name = 'biscuit' } diff --git a/lua/plugins/catppuccin-nvim.lua b/lua/plugins/catppuccin-nvim.lua new file mode 100644 index 0000000..4d02be2 --- /dev/null +++ b/lua/plugins/catppuccin-nvim.lua @@ -0,0 +1,6 @@ +return { + 'catppuccin/nvim', + lazy=false, + priority = 1000, +} + diff --git a/lua/plugins/everforest.lua b/lua/plugins/everforest.lua new file mode 100644 index 0000000..f3951d0 --- /dev/null +++ b/lua/plugins/everforest.lua @@ -0,0 +1 @@ +return {'sainnhe/everforest'} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..8d6e310 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,55 @@ +return { + 'lewis6991/gitsigns.nvim', + event = { 'BufEnter' }, + config = function() + require('gitsigns').setup { + signs = { + add = { text = '█' }, + change = { text = '█' }, + delete = { text = '█' }, + topdelete = { text = '█' }, + changedelete = { text = '█' }, + untracked = { text = '█' }, + }, + signs_staged = { + add = { text = '█' }, + change = { text = '█' }, + delete = { text = '█' }, + topdelete = { text = '█' }, + changedelete = { text = '█' }, + untracked = { text = '█' }, + }, + signs_staged_enable = true, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + follow_files = true + }, + auto_attach = true, + attach_to_untracked = false, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + virt_text_priority = 100, + }, + current_line_blame_formatter = ', - ', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + border = 'single', + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + } + end +} diff --git a/lua/plugins/gruvbox.lua b/lua/plugins/gruvbox.lua new file mode 100644 index 0000000..b81cdea --- /dev/null +++ b/lua/plugins/gruvbox.lua @@ -0,0 +1 @@ +return { "ellisonleao/gruvbox.nvim", priority = 1000} diff --git a/lua/plugins/hy.lua b/lua/plugins/hy.lua new file mode 100644 index 0000000..9340bbe --- /dev/null +++ b/lua/plugins/hy.lua @@ -0,0 +1,6 @@ +return { + 'hylang/vim-hy', + config=function() + vim.g.hy_enable_conceal = 1 + end +} diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..502f753 --- /dev/null +++ b/lua/plugins/indent-blankline.lua @@ -0,0 +1,7 @@ +return { + -- "lukas-reineke/indent-blankline.nvim", + -- main = "ibl", + -- config = function() + -- require("ibl").setup() + -- end +} diff --git a/lua/plugins/mason-lspconfig.lua b/lua/plugins/mason-lspconfig.lua new file mode 100644 index 0000000..5923b92 --- /dev/null +++ b/lua/plugins/mason-lspconfig.lua @@ -0,0 +1 @@ +return {'williamboman/mason-lspconfig.nvim'} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..60e0e17 --- /dev/null +++ b/lua/plugins/mason.lua @@ -0,0 +1,7 @@ +return { + 'williamboman/mason.nvim', + lazy = true, + config = function() + require('mason').setup() + end +} diff --git a/lua/plugins/mini-files.lua b/lua/plugins/mini-files.lua new file mode 100644 index 0000000..6564fc9 --- /dev/null +++ b/lua/plugins/mini-files.lua @@ -0,0 +1 @@ +return { 'echasnovski/mini.files', version = false } diff --git a/lua/plugins/mini-notify.lua b/lua/plugins/mini-notify.lua new file mode 100644 index 0000000..74d1e39 --- /dev/null +++ b/lua/plugins/mini-notify.lua @@ -0,0 +1 @@ +return { 'echasnovski/mini.notify', version = false } diff --git a/lua/plugins/mini-pairs.lua b/lua/plugins/mini-pairs.lua new file mode 100644 index 0000000..3d744a3 --- /dev/null +++ b/lua/plugins/mini-pairs.lua @@ -0,0 +1 @@ +return { 'echasnovski/mini.pairs', version = false } diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua new file mode 100644 index 0000000..fd321e8 --- /dev/null +++ b/lua/plugins/neotree.lua @@ -0,0 +1,14 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + event = { "VeryLazy" }, + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + }, + config = function() + vim.api.nvim_set_keymap('n', '', ':UndotreeHide:Neotree toggle', {}) + end +} diff --git a/lua/plugins/nui.lua b/lua/plugins/nui.lua new file mode 100644 index 0000000..0e20f98 --- /dev/null +++ b/lua/plugins/nui.lua @@ -0,0 +1 @@ +return {'MunifTanjim/nui.nvim'} diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..2eabf74 --- /dev/null +++ b/lua/plugins/nvim-cmp.lua @@ -0,0 +1,210 @@ +return { + "hrsh7th/nvim-cmp", + event = { "InsertEnter" }, + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + "L3MON4D3/LuaSnip", -- snippet engine + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-omni", + "hrsh7th/cmp-emoji", + 'hrsh7th/cmp-nvim-lsp-signature-help', + 'f3fora/cmp-spell', + 'hrsh7th/cmp-calc', + 'ray-x/cmp-treesitter', + 'hrsh7th/cmp-cmdline', + 'tzachar/cmp-ai' + }, + config = function() + -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) + require("luasnip.loaders.from_vscode").lazy_load() + + local cmp_status_ok, cmp = pcall(require, "cmp") + if not cmp_status_ok then + return + end + + local snip_status_ok, luasnip = pcall(require, "luasnip") + if not snip_status_ok then + return + end + + require("luasnip/loaders/from_vscode").lazy_load() + + local check_backspace = function() + local col = vim.fn.col "." - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" + end + + local cmp_ai = require('cmp_ai.config') + + cmp_ai:setup({ + max_lines = 100, + provider = 'Ollama', + provider_options = { + model = 'codellama:7b-code', + }, + notify = true, + notify_callback = function(msg) + vim.notify(msg) + end, + run_on_every_keystroke = false, + ignored_file_types = { + -- default is not to ignore + -- uncomment to ignore in lua: + -- lua = true + }, + }) + + local kind_icons = { + Text = "󰉿", + Method = "󰆧", + Function = "󰊕", + Constructor = "", + Field = " ", + Variable = "󰀫", + Class = "󰠱", + Interface = "", + Module = "", + Property = "󰜢", + Unit = "󰑭", + Value = "󰎠", + Enum = "", + Keyword = "󰌋", + Snippet = "", + Color = "󰏘", + File = "󰈙", + Reference = "", + Folder = "󰉋", + EnumMember = "", + Constant = "󰏿", + Struct = "", + Event = "", + Operator = "󰆕", + TypeParameter = " ", + Misc = " ", + } + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [""] = cmp.mapping { + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }, + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm { select = true }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + 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", + }), + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + vim_item.menu = ({ + nvim_lsp = "[LSP]", + luasnip = "[Snip]", + buffer = "[Buf]", + path = "[Path]", + cmp_ai = '[AI]', + })[entry.source.name] + return vim_item + end, + }, + completion = { + autocomplete = { + require('cmp.types').cmp.TriggerEvent.TextChanged, + }, + completeopt = 'menu,menuone,noselect', + keyword_pattern = ".*", + keyword_length = 1, -- Set to 1 for immediate as-you-type completion + }, + sources = { + { name = 'nvim_lsp_signature_help' }, + { name = "nvim_lsp" }, + -- { name = 'cmp_ai' }, + { name = "treesitter" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + { name = "spell" }, + { name = 'calc' }, + { name = 'omni' }, + { name = 'emoji' } + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { + ghost_text = true, + native_menu = false, + }, + } + + -- `/` cmdline setup. + cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }) + + -- `:` cmdline setup. + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + end, +} + diff --git a/lua/plugins/nvim-colorizer.lua b/lua/plugins/nvim-colorizer.lua new file mode 100644 index 0000000..45ec2c1 --- /dev/null +++ b/lua/plugins/nvim-colorizer.lua @@ -0,0 +1,5 @@ +return { + "NvChad/nvim-colorizer.lua", + event = { "BufReadPre", "BufNewFile" }, + config = true, +} diff --git a/lua/plugins/nvim-emmet.lua b/lua/plugins/nvim-emmet.lua new file mode 100644 index 0000000..beb199b --- /dev/null +++ b/lua/plugins/nvim-emmet.lua @@ -0,0 +1,7 @@ +return { + "olrtg/nvim-emmet", + lazy=false, + config = function() + vim.keymap.set({ "n", "v" }, 'xe', require('nvim-emmet').wrap_with_abbreviation) + end, +} diff --git a/lua/plugins/nvim-lint.lua b/lua/plugins/nvim-lint.lua new file mode 100644 index 0000000..6c8f208 --- /dev/null +++ b/lua/plugins/nvim-lint.lua @@ -0,0 +1,10 @@ +return { + 'mfussenegger/nvim-lint', + event = { "VeryLazy" }, + config = function() + require('lint').linters_by_ft = { + markdown = {'vale',}, + python = {'pylint',}, + } + end +} diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua new file mode 100644 index 0000000..293d99e --- /dev/null +++ b/lua/plugins/nvim-lspconfig.lua @@ -0,0 +1,100 @@ +local function on_attach(client, bufnr) + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, {}) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, {}) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, {}) + vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, {}) + vim.keymap.set('n', 'h', vim.lsp.buf.hover, {}) +end + +local servers = { + 'asm_lsp', + 'bashls', + 'clojure_lsp', + 'cmake', + 'cssls', + 'fennel_language_server', + 'html', + 'jqls', + 'jsonls', + 'pyright', + 'rust_analyzer', + 'clangd', + 'verible', + 'vimls', + 'luau_lsp', + 'lua_ls', + 'emmet_language_server', + } + + +local border = 'rounded' + +local handlers = { + ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border, focus = false}), + ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border, focus = false}), +} + +-- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { +-- group = vim.api.nvim_create_augroup("float_diagnostic", { clear = true }), +-- callback = function () +-- vim.lsp.buf.hover(nil, {focus=false, scope='line'}) +-- end +-- }) + +return { + event={ "VeryLazy" }, + 'neovim/nvim-lspconfig', + config = function() + local nvim_lsp = require('lspconfig') + require('mason') + require('mason-lspconfig').setup({ + ensure_installed = servers + }) + for _, lsp in ipairs(servers) do + local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities() + + if lsp ~= 'emmet-language-server' then + nvim_lsp[lsp].setup { + on_attach = on_attach, + autostart = true, + capabilities = lsp_capabilities, + handlers = handlers, + flags = { + debounce_text_changes = 150, + } + } + else + nvim_lsp.emmet_language_server.setup({ + filetypes = { "css", "eruby", "html", "javascript", "javascriptreact", "less", "sass", "scss", "pug", "typescriptreact" }, + -- Read more about this options in the [vscode docs](https://code.visualstudio.com/docs/editor/emmet#_emmet-configuration). + -- **Note:** only the options listed in the table are supported. + init_options = { + ---@type table + includeLanguages = {}, + --- @type string[] + excludeLanguages = {}, + --- @type string[] + extensionsPath = {}, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/preferences/) + preferences = {}, + --- @type boolean Defaults to `true` + showAbbreviationSuggestions = true, + --- @type "always" | "never" Defaults to `"always"` + showExpandedAbbreviation = "always", + --- @type boolean Defaults to `false` + showSuggestionsAsSnippets = false, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/syntax-profiles/) + syntaxProfiles = {}, + --- @type table [Emmet Docs](https://docs.emmet.io/customization/snippets/#variables) + variables = {}, + }, + }) + end + end + vim.cmd([[LspStart]]) + end +} + + diff --git a/lua/plugins/nvim-navic.lua b/lua/plugins/nvim-navic.lua new file mode 100644 index 0000000..e6c879a --- /dev/null +++ b/lua/plugins/nvim-navic.lua @@ -0,0 +1,51 @@ +return { + 'SmiteshP/nvim-navic', + event = { 'LspAttach' }, + config = function() + local navic = require('nvim-navic') + navic.setup { + icons = { + File = ' ', + Module = ' ', + Namespace = ' ', + Package = ' ', + Class = ' ', + Method = ' ', + Property = ' ', + Field = ' ', + Constructor = ' ', + Enum = ' ', + Interface = ' ', + Function = ' ', + Variable = ' ', + Constant = ' ', + String = ' ', + Number = ' ', + Boolean = ' ', + Array = ' ', + Object = ' ', + Key = ' ', + Null = ' ', + EnumMember = ' ', + Struct = ' ', + Event = ' ', + Operator = ' ', + TypeParameter = ' ' + }, + lsp = { + auto_attach = true, + preference = nil, + }, + highlight = true, + separator = " > ", + depth_limit = 0, + depth_limit_indicator = "..", + safe_output = true, + lazy_update_context = false, + click = true, + format_text = function(text) + return text + end, + } + end +} diff --git a/lua/plugins/nvim-telescope.lua b/lua/plugins/nvim-telescope.lua new file mode 100644 index 0000000..eb4f27f --- /dev/null +++ b/lua/plugins/nvim-telescope.lua @@ -0,0 +1,54 @@ +return { + lazy = true, + 'nvim-telescope/telescope.nvim', + tag = '0.1.4', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local actions = require("telescope.actions") + local keymap = vim.api.nvim_set_keymap + + require('telescope').setup({ + extensions = { + media = { + backend = "ueberzug", + backend_options = { + xmove = -1, + ymove = -2, + warnings = true, + supress_backend_warning = false + }, + } + }, + defaults = { + prompt_prefix = "λ ", + selection_caret = "-> ", + mappings = { + i = { + [""] = actions.which_key, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + } + } + }, + pickers = { + buffers = { + sort_lastused = true, + previewer = false, + layout_config = { + width = 0.3, + height = 0.4, + }, + }, + planets = { + show_pluto = true, + }, + }, + extensions = {} + }) + keymap('n', '', ':Telescope find_files', {}) + keymap('n', 'm', ':Telescope media', {}) + keymap('n', 'b', ':Telescope buffers', {}) + keymap('n', 't', ':Telescope', {}) + keymap('n', 'g', ':Telescope live_grep', {}) + end, +} diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..aa0febd --- /dev/null +++ b/lua/plugins/nvim-treesitter.lua @@ -0,0 +1,72 @@ +return { + "nvim-treesitter/nvim-treesitter", + event = { "InsertEnter" }, + build = ":TSUpdate", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + "windwp/nvim-ts-autotag", + }, + config = function() + -- import nvim-treesitter plugin + local treesitter = require("nvim-treesitter.configs") + + -- configure treesitter + treesitter.setup({ -- enable syntax highlighting + auto_install = true, + + highlight = { + enable = true, + }, + -- enable indentation + indent = { enable = true }, + -- enable autotagging (w/ nvim-ts-autotag plugin) + autotag = { + enable = true, + }, + -- ensure these language parsers are installed + ensure_installed = { + "json", + "javascript", + "yaml", + "html", + "markdown", + "markdown_inline", + "bash", + "lua", + "vim", + "dockerfile", + "gitignore", + "query", + "latex", + "python", + "c", + "cpp", + "css", + "commonlisp", + "fennel", + "haskell", + "ini", + "jq", + "perl", + "scss", + "verilog", + "awk" + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + -- enable nvim-ts-context-commentstring plugin for commenting tsx and jsx + context_commentstring = { + enable = true, + enable_autocmd = false, + }, + }) + vim.api.nvim_set_keymap('n', 'jd', ':TSD', { noremap = true, silent = true }) + end, +} diff --git a/lua/plugins/oxocarbon.lua b/lua/plugins/oxocarbon.lua new file mode 100644 index 0000000..668a011 --- /dev/null +++ b/lua/plugins/oxocarbon.lua @@ -0,0 +1 @@ +return { 'nyoom-engineering/oxocarbon.nvim' } diff --git a/lua/plugins/rosepine.lua b/lua/plugins/rosepine.lua new file mode 100644 index 0000000..2f118a9 --- /dev/null +++ b/lua/plugins/rosepine.lua @@ -0,0 +1 @@ +return { 'rose-pine/neovim', name = 'rose-pine' } diff --git a/lua/plugins/tabby.lua b/lua/plugins/tabby.lua new file mode 100644 index 0000000..ded2e58 --- /dev/null +++ b/lua/plugins/tabby.lua @@ -0,0 +1,51 @@ +return { + 'nanozuki/tabby.nvim', + dependencies = 'nvim-tree/nvim-web-devicons', + config = function() + local theme = { + fill = 'TabLineFill', + -- Also you can do this: fill = { fg='#f2e9de', bg='#907aa9', style='italic' } + head = 'TabLine', + current_tab = 'tabActive', + tab = 'TabLine', + win = 'TabLine', + tail = 'TabLine', + } + require('tabby').setup({ + line = function(line) + return { + { + line.sep(' ', theme.head, theme.fill), + }, + line.tabs().foreach(function(tab) + local hl = tab.is_current() and theme.current_tab or theme.tab + return { + tab.number(), + tab.name(), + tab.close_btn(''), + line.sep(' ', hl, theme.fill), + hl = hl, + margin = ' ', + } + end), + line.spacer(), + line.wins_in_tab(line.api.get_current_tab()).foreach(function(win) + return { + line.sep(' ', theme.win, theme.fill), + win.buf_name(), + line.sep(' ', theme.win, theme.fill), + hl = theme.win, + margin = ' ', + } + end), + { + line.sep(' ', theme.tail, theme.fill), + { '', hl = theme.tail }, + }, + hl = theme.fill, + } + end, + -- option = {}, -- setup modules' option, + }) + end, +} diff --git a/lua/plugins/tagbar.lua b/lua/plugins/tagbar.lua new file mode 100644 index 0000000..030492b --- /dev/null +++ b/lua/plugins/tagbar.lua @@ -0,0 +1,6 @@ +return { + 'preservim/tagbar', + config = function() + vim.keymap.set('n', 'o', ':TagbarToggle', {}) + end +} diff --git a/lua/plugins/telescope-media.lua b/lua/plugins/telescope-media.lua new file mode 100644 index 0000000..7712189 --- /dev/null +++ b/lua/plugins/telescope-media.lua @@ -0,0 +1,7 @@ +return { + "dharmx/telescope-media.nvim", + event={ "VeryLazy" }, + config = function() + require("telescope").load_extension("media") + end, +} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..ef94464 --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,10 @@ +return { + 'akinsho/toggleterm.nvim', + version = "*", + event = { "VeryLazy" }, + config = function() + require('toggleterm').setup({ + open_mapping = [[]], + }) + end +} diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua new file mode 100644 index 0000000..fbe3fef --- /dev/null +++ b/lua/plugins/trouble.lua @@ -0,0 +1,16 @@ +return { + "folke/trouble.nvim", + event = { "LspAttach" }, + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + signs = { + -- icons / text used for a diagnostic + error = "", + warning = "", + hint = "", + information = "", + other = "", + }, + }, +} + diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua new file mode 100644 index 0000000..e5fb95a --- /dev/null +++ b/lua/plugins/undotree.lua @@ -0,0 +1,6 @@ +return { + 'mbbill/undotree', + config=function() + vim.keymap.set('n', '', ':Neotree close:UndotreeToggle', {}) + end, +} diff --git a/lua/plugins/vim-commentary.lua b/lua/plugins/vim-commentary.lua new file mode 100644 index 0000000..39cd86e --- /dev/null +++ b/lua/plugins/vim-commentary.lua @@ -0,0 +1 @@ +return {'tpope/vim-commentary'} diff --git a/lua/plugins/vim-sleuth.lua b/lua/plugins/vim-sleuth.lua new file mode 100644 index 0000000..f2b0cba --- /dev/null +++ b/lua/plugins/vim-sleuth.lua @@ -0,0 +1 @@ +return { 'tpope/vim-sleuth', event = { 'BufEnter' }} diff --git a/lua/plugins/vim-surround.lua b/lua/plugins/vim-surround.lua new file mode 100644 index 0000000..cf307ae --- /dev/null +++ b/lua/plugins/vim-surround.lua @@ -0,0 +1 @@ +return {'tpope/vim-surround'} diff --git a/lua/plugins/vimtex.lua b/lua/plugins/vimtex.lua new file mode 100644 index 0000000..07c18bf --- /dev/null +++ b/lua/plugins/vimtex.lua @@ -0,0 +1,8 @@ +return { + 'lervag/vimtex', + config = function() + vim.g.vimtex_view_method = 'zathura' + vim.api.nvim_set_keymap('n', 'll', [[:VimtexCompile]], { noremap = true, silent = true }) + end, + event = "FileType tex" +}