commit abca7e20d5c244ceb3a3bcb84b226e18e17876aa Author: nya Date: Fri Dec 30 18:28:47 2022 +0100 Initial configuration diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..895f911 --- /dev/null +++ b/init.lua @@ -0,0 +1,407 @@ +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +local wo = vim.wo +local bo = vim.bo + +vim.opt.termguicolors = true +bo.tabstop = 2 +bo.shiftwidth = 2 +bo.autoindent = true +bo.expandtab = true +wo.number = 1 +wo.relativenumber = 1 + +print('nya~') + +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() + +local packer = require('packer') +packer.startup(function(use) + use 'wbthomason/packer.nvim' + use 'nvim-lua/plenary.nvim' + use 'nvim-treesitter/nvim-treesitter' + use 'neovim/nvim-lspconfig' + use 'mfussenegger/nvim-dap' + use 'jose-elias-alvarez/null-ls.nvim' + use 'nvim-telescope/telescope.nvim' + use 'lewis6991/gitsigns.nvim' + use 'williamboman/mason.nvim' + use 'williamboman/mason-lspconfig.nvim' + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/nvim-cmp' + use 'hrsh7th/vim-vsnip' + use 'onsails/lspkind.nvim' + use 'antoinemadec/FixCursorHold.nvim' + use 'olimorris/onedarkpro.nvim' + use { + 'weilbith/nvim-code-action-menu', + cmd = 'CodeActionMenu' + } + use { + "folke/trouble.nvim", + requires = "kyazdani42/nvim-web-devicons", + config = function() + require("trouble").setup { + position = "bottom", -- position of the list can be: bottom, top, left, right + height = 10, -- height of the trouble list when position is top or bottom + width = 50, -- width of the list when position is left or right + icons = true, -- use devicons for filenames + mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" + fold_open = "", -- icon used for open folds + fold_closed = "", -- icon used for closed folds + group = true, -- group results by file + padding = true, -- add an extra new line on top of the list + action_keys = { -- key mappings for actions in the trouble list + -- map to {} to remove a mapping, for example: + -- close = {}, + close = "q", -- close the list + cancel = "", -- cancel the preview and get back to your last window / buffer / cursor + refresh = "r", -- manually refresh + jump = {"", ""}, -- jump to the diagnostic or open / close folds + open_split = { "" }, -- open buffer in new split + open_vsplit = { "" }, -- open buffer in new vsplit + open_tab = { "" }, -- open buffer in new tab + jump_close = {"o"}, -- jump to the diagnostic and close the list + toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode + toggle_preview = "P", -- toggle auto_preview + hover = "K", -- opens a small popup with the full multiline message + preview = "p", -- preview the diagnostic location + close_folds = {"zM", "zm"}, -- close all folds + open_folds = {"zR", "zr"}, -- open all folds + toggle_fold = {"zA", "za"}, -- toggle fold of current file + previous = "k", -- previous item + next = "j" -- next item + }, + indent_lines = true, -- add an indent guide below the fold icons + auto_open = true, -- automatically open the list when you have diagnostics + auto_close = true, -- automatically close the list when you have no diagnostics + auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window + auto_fold = false, -- automatically fold a file trouble list at creation + auto_jump = {"lsp_definitions"}, -- for the given modes, automatically jump if there is only a single result + signs = { + -- icons / text used for a diagnostic + error = "", + warning = "", + hint = "", + information = "", + other = "﫠" + }, + use_diagnostic_signs = true + } + end + } + use { + 'nvim-tree/nvim-tree.lua', + requires = { + 'nvim-tree/nvim-web-devicons', -- optional, for file icons + } + } + use 'nvim-tree/nvim-web-devicons' + use 'lukas-reineke/indent-blankline.nvim' + use 'norcalli/nvim-colorizer.lua' + use { + 'goolord/alpha-nvim', + requires = { 'nvim-tree/nvim-web-devicons' }, + config = function () + require('alpha').setup(require('alpha.themes.startify').config) + end + } + use { + 'numToStr/Comment.nvim', + config = function() + require('Comment').setup() + end + } + use { + 'akinsho/bufferline.nvim', tag = "v3.*", + config = function() + require("bufferline").setup() + end, + requires = 'nvim-tree/nvim-web-devicons' + } + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/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) + +packer.install() + +vim.cmd("colorscheme onedark") + + +vim.g.code_action_menu_window_border = 'single' +vim.g.code_action_menu_show_details = true +vim.g.code_action_menu_show_diff = true + +require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + -- 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, + }, +} + + +require("mason").setup() +require('lspconfig')['tsserver'].setup{ + on_attach = on_attach, + flags = lsp_flags, +} +require('lspconfig')['rust_analyzer'].setup{ + on_attach = on_attach, + flags = lsp_flags, + -- Server-specific settings... + settings = { + ["rust-analyzer"] = {} + } +} +require'lspconfig'.sumneko_lua.setup { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'}, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, +} + +require'lspconfig'.omnisharp.setup { + capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), + cmd = { "dotnet", "/home/nya/.vscode-oss/extensions/ms-dotnettools.csharp-1.25.2-linux-x64/.omnisharp/1.39.2-net6.0/OmniSharp.dll" }, + + -- Enables support for reading code style, naming convention and analyzer + -- settings from .editorconfig. + enable_editorconfig_support = true, + + -- If true, MSBuild project system will only load projects for files that + -- were opened in the editor. This setting is useful for big C# codebases + -- and allows for faster initialization of code navigation features only + -- for projects that are relevant to code that is being edited. With this + -- setting enabled OmniSharp may load fewer projects and may thus display + -- incomplete reference lists for symbols. + enable_ms_build_load_projects_on_demand = false, + + -- Enables support for roslyn analyzers, code fixes and rulesets. + enable_roslyn_analyzers = true, + + -- Specifies whether 'using' directives should be grouped and sorted during + -- document formatting. + organize_imports_on_format = true, + + -- Enables support for showing unimported types and unimported extension + -- methods in completion lists. When committed, the appropriate using + -- directive will be added at the top of the current file. This option can + -- have a negative impact on initial completion responsiveness, + -- particularly for the first few completion sessions after opening a + -- solution. + enable_import_completion = true, + + -- Specifies whether to include preview versions of the .NET SDK when + -- determining which version to use for project loading. + sdk_include_prereleases = true, + + -- Only run analyzers against open files when 'enableRoslynAnalyzers' is + -- true + analyze_open_documents_only = false, +} + +require("mason-lspconfig").setup({ + ensure_installed = { "sumneko_lua", "rust_analyzer" } +}) + +local cmp = require('cmp') + +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 + +local feedkey = function(key, mode) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) +end + +cmp.setup { + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = { + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + elseif has_words_before() then + cmp.complete() + else + fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. + end + end, { "i", "s" }), + + [""] = cmp.mapping(function() + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#jumpable"](-1) == 1 then + feedkey("(vsnip-jump-prev)", "") + end + end, { "i", "s" }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }, + formatting = { + format = require('lspkind').cmp_format { + with_text = true, + menu = { + buffer = "[buf]", + nvim_lsp = "[LSP]", + path = "[path]", + }, + }, + }, + + sources = { + { name = "nvim_lsp"}, + { name = "path" }, + { name = "buffer" , keyword_length = 5}, + }, + experimental = { + ghost_text = true + } +} + +require("nvim-tree").setup({ + open_on_setup = true, + sort_by = "case_sensitive", + view = { + adaptive_size = true, + mappings = { + list = { + { key = "u", action = "dir_up" }, + }, + }, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = true, + }, +}) + +require("indent_blankline").setup { + show_current_context = true, + show_current_context_start = true, +} + +require('colorizer').setup() +require("bufferline").setup { + options = { + show_buffer_icons = true, + indicator = { + style = 'underline', + }, + diagnostics = "nvim_lsp", + diagnostics_update_in_insert = true, + color_icons = true, + show_buffer_close_icons = true, + show_buffer_icons = true, + hover = { + enabled = true, + delay = 200, + reveal = {'close'} + } + } +} + +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} + +vim.api.nvim_set_keymap('n', '', ':NvimTreeFocus', { noremap = true }) +vim.api.nvim_set_keymap('n', '', ':TroubleToggle', { noremap = true }) diff --git a/lua/.luarc.json b/lua/.luarc.json new file mode 100644 index 0000000..a7a1ee4 --- /dev/null +++ b/lua/.luarc.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.workspace.library": [ + "/home/nya/.config/nvim", + "/etc/xdg/nvim", + "/home/nya/.local/share/nvim/site", + "/home/nya/.local/share/nvim/site/pack/packer/start/Comment.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/alpha-nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/bufferline.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/lualine.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/mason.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/null-ls.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua", + "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-dap", + "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", + "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + "/home/nya/.local/share/nvim/site/pack/packer/start/onedarkpro.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/packer.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/plenary.nvim", + "/home/nya/.local/share/nvim/site/pack/packer/start/telescope.nvim", + "/usr/share/nvim/runtime", + "/usr/lib/nvim", + "/usr/share/vim/vimfiles", + "${3rd}/luassert/library" + ] +} \ No newline at end of file diff --git a/lua/gitsigns.lua b/lua/gitsigns.lua new file mode 100644 index 0000000..91fa65b --- /dev/null +++ b/lua/gitsigns.lua @@ -0,0 +1 @@ +require('gitsigns').setup() diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua new file mode 100644 index 0000000..3f7a4ec --- /dev/null +++ b/plugin/packer_compiled.lua @@ -0,0 +1,179 @@ +-- 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 = "/home/nya/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/nya/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/nya/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/nya/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/home/nya/.cache/nvim/packer_hererocks/2.1.0-beta3/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 = { + ["alpha-nvim"] = { + config = { "\27LJ\2\n`\0\0\5\0\5\0\n6\0\0\0'\2\1\0B\0\2\0029\0\2\0006\2\0\0'\4\3\0B\2\2\0029\2\4\2B\0\2\1K\0\1\0\vconfig\26alpha.themes.startify\nsetup\nalpha\frequire\0" }, + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/alpha-nvim", + url = "https://github.com/goolord/alpha-nvim" + }, + ["gitsigns.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", + url = "https://github.com/lewis6991/gitsigns.nvim" + }, + ["indent-blankline.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim", + url = "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + ["mason-lspconfig.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", + url = "https://github.com/williamboman/mason-lspconfig.nvim" + }, + ["mason.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/mason.nvim", + url = "https://github.com/williamboman/mason.nvim" + }, + ["null-ls.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/null-ls.nvim", + url = "https://github.com/jose-elias-alvarez/null-ls.nvim" + }, + ["nvim-colorizer.lua"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua", + url = "https://github.com/norcalli/nvim-colorizer.lua" + }, + ["nvim-dap"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-dap", + url = "https://github.com/mfussenegger/nvim-dap" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-tree.lua"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", + url = "https://github.com/nvim-tree/nvim-tree.lua" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + url = "https://github.com/nvim-tree/nvim-web-devicons" + }, + ["onedarkpro.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/onedarkpro.nvim", + url = "https://github.com/olimorris/onedarkpro.nvim" + }, + ["packer.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/home/nya/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + } +} + +time([[Defining packer_plugins]], false) +-- Config for: alpha-nvim +time([[Config for alpha-nvim]], true) +try_loadstring("\27LJ\2\n`\0\0\5\0\5\0\n6\0\0\0'\2\1\0B\0\2\0029\0\2\0006\2\0\0'\4\3\0B\2\2\0029\2\4\2B\0\2\1K\0\1\0\vconfig\26alpha.themes.startify\nsetup\nalpha\frequire\0", "config", "alpha-nvim") +time([[Config for alpha-nvim]], 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