From 86d097130ef830c34916175bc7de52818aa63e78 Mon Sep 17 00:00:00 2001 From: roodletoof <68161791+roodletoof@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:12:03 +0100 Subject: [PATCH] added marker folds --- init.lua | 262 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 132 insertions(+), 130 deletions(-) diff --git a/init.lua b/init.lua index 35956a6..9266b7b 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,5 @@ --- vim:foldmethod=indent --- GENERAL SETTINGS +-- vim:foldmethod=marker +-- GENERAL SETTINGS {{{1 vim.opt.tabstop = 8 vim.opt.shiftwidth = 0 @@ -64,7 +64,7 @@ vim.g.python_indent = { -- Fixes retarded default python indentation. searchpair_timeout = 300, } -local function file_exists(name) +local function file_exists(name) --{{{1 local f = io.open(name,"r") if f~=nil then f:close() @@ -75,7 +75,7 @@ local function file_exists(name) end --- LAZY.NVIM BOOTSTRAP +-- LAZY.NVIM BOOTSTRAP {{{1 local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then vim.fn.system({ @@ -89,17 +89,19 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) -require'lazy'.setup{ - { 'justinmk/vim-sneak', }, - { 'michaeljsmith/vim-indent-object', }, - { 'kylechui/nvim-surround', +require'lazy'.setup{ --{{{1 + { 'justinmk/vim-sneak', --{{{2 + }, + { 'michaeljsmith/vim-indent-object', --{{{2 + }, + { 'kylechui/nvim-surround', --{{{2 version = '*', -- Use for stability; omit to use `main` branch for the latest features event = 'VeryLazy', config = function() require('nvim-surround').setup{} end }, - { 'sainnhe/everforest', + { 'sainnhe/everforest', --{{{2 lazy = false, priority = 1000, config = function() @@ -108,7 +110,7 @@ require'lazy'.setup{ vim.cmd.colorscheme('everforest') end, }, - { 'folke/zen-mode.nvim', + { 'folke/zen-mode.nvim', --{{{2 config = function () vim.keymap.set( 'n', @@ -118,7 +120,7 @@ require'lazy'.setup{ ) end }, - { 'stevearc/oil.nvim', + { 'stevearc/oil.nvim', --{{{2 dependencies = { 'nvim-tree/nvim-web-devicons', }, config = function () local oil = require('oil') @@ -132,7 +134,124 @@ require'lazy'.setup{ vim.keymap.set("n", "-", vim.cmd.Oil, { desc = "Open parent directory" }) end, }, - { 'nvim-telescope/telescope.nvim', + { 'neovim/nvim-lspconfig', --{{{2 + config = function() + require'lspconfig'.gopls.setup{} + require'lspconfig'.rust_analyzer.setup{} + require'lspconfig'.gdscript.setup{} + require'lspconfig'.clangd.setup{} + require'lspconfig'.pyright.setup{} + require'lspconfig'.ts_ls.setup{} + vim.cmd [[ + noremap ,rn :lua vim.lsp.buf.rename() + noremap ,fd :lua vim.lsp.buf.definition() + noremap ,ft :lua vim.lsp.buf.type_definition() + noremap ,fr :lua vim.lsp.buf.references() + noremap ,ca :lua vim.lsp.buf.code_action() + noremap ,oe :lua vim.diagnostic.open_float() + noremap ,ea :lua vim.diagnostic.setqflist() + noremap ,ee :lua vim.diagnostic.setqflist{severity="ERROR"} + noremap ,ew :lua vim.diagnostic.setqflist{severity="WARN"} + noremap ,ei :lua vim.diagnostic.setqflist{severity="INFO"} + noremap ,eh :lua vim.diagnostic.setqflist{severity="HINT"} + ]] + end + }, + { 'mfussenegger/nvim-dap', --{{{2 + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'theHamsta/nvim-dap-virtual-text', + 'leoluz/nvim-dap-go', + 'mfussenegger/nvim-dap-python', + }, + + config = function() + require'nvim-dap-virtual-text'.setup{ commented = true, } + require'dap-go'.setup() + require'dap-python'.setup(vim.fn.stdpath('config') .. '/.venv/bin/python') + + local dap = require'dap' + dap.adapters.godot = { type = 'server', host = '127.0.0.1', port = 6006, } + dap.configurations.gdscript = { {type = 'godot', request = 'launch', name = 'Launch scene', project = "${workspaceFolder}",} } + + vim.cmd [[ + nnoremap ,b :DapToggleBreakpoint + nnoremap ,B :DapClearBreakpoints + nnoremap + nnoremap ,db :DapContinue + nnoremap :DapStepInto + nnoremap :DapStepOut + nnoremap :DapStepOver + ]] + end + }, + { 'dcampos/nvim-snippy', --{{{2 + config = function() + require'snippy'.setup{ enable_auto = true, } + vim.cmd [[ + imap '(snippy-next)' + imap '(snippy-previous)' + smap '(snippy-next)' + smap '(snippy-previous)' + xmap (snippy-cut-text) + ]] + + vim.api.nvim_create_user_command( + 'S', + function () + ---@type string + local snippets_path = vim.fn.stdpath('config') .. '/snippets/' .. vim.api.nvim_buf_get_option(0, "filetype") .. '.snippets' + + if not file_exists(snippets_path) then + local file = io.open( snippets_path, 'w' ) + assert( + file ~= nil, + ("io.open('%s', 'w') returned nil.\n"):format(snippets_path) .. + "Make sure the snippets folder in the above path exists." + ) + file:close() + print('created file: ', snippets_path) + end + + vim.api.nvim_command(('SnippyEdit %s'):format(snippets_path)) + end, + { nargs = 0 } + ) + end + }, + { 'hrsh7th/nvim-cmp', --{{{2 + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'dcampos/nvim-snippy', + 'dcampos/cmp-snippy', + }, + config = function() + local cmp = require'cmp' + cmp.setup{ + snippet = { + expand = function(args) + require'snippy'.expand_snippet(args.body) + end, + }, + mapping = { + [''] = cmp.mapping.confirm{ select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + }, + sources = cmp.config.sources( + { + { name = 'snippy', priority = 100000000000000000000 }, + { name = 'nvim_lsp', priority = 100}, + { name = 'path', priority = 1}, + } + ), + preselect = cmp.PreselectMode.None, + } + end, + }, + { 'nvim-telescope/telescope.nvim', --{{{2 tag = '0.1.8', dependencies = { 'nvim-lua/plenary.nvim', @@ -170,126 +289,9 @@ require'lazy'.setup{ require'telescope'.load_extension'ui-select' end, }, - { 'neovim/nvim-lspconfig', - config = function() - require'lspconfig'.gopls.setup{} - require'lspconfig'.rust_analyzer.setup{} - require'lspconfig'.gdscript.setup{} - require'lspconfig'.clangd.setup{} - require'lspconfig'.pyright.setup{} - require'lspconfig'.ts_ls.setup{} - vim.cmd [[ - noremap ,rn :lua vim.lsp.buf.rename() - noremap ,fd :lua vim.lsp.buf.definition() - noremap ,ft :lua vim.lsp.buf.type_definition() - noremap ,fr :lua vim.lsp.buf.references() - noremap ,ca :lua vim.lsp.buf.code_action() - noremap ,oe :lua vim.diagnostic.open_float() - noremap ,ea :lua vim.diagnostic.setqflist() - noremap ,ee :lua vim.diagnostic.setqflist{severity="ERROR"} - noremap ,ew :lua vim.diagnostic.setqflist{severity="WARN"} - noremap ,ei :lua vim.diagnostic.setqflist{severity="INFO"} - noremap ,eh :lua vim.diagnostic.setqflist{severity="HINT"} - ]] - end - }, - { 'mfussenegger/nvim-dap', - dependencies = { - 'nvim-treesitter/nvim-treesitter', - 'theHamsta/nvim-dap-virtual-text', - 'leoluz/nvim-dap-go', - 'mfussenegger/nvim-dap-python', - }, - - config = function() - require'nvim-dap-virtual-text'.setup{ commented = true, } - require'dap-go'.setup() - require'dap-python'.setup(vim.fn.stdpath('config') .. '/.venv/bin/python') - - local dap = require'dap' - dap.adapters.godot = { type = 'server', host = '127.0.0.1', port = 6006, } - dap.configurations.gdscript = { {type = 'godot', request = 'launch', name = 'Launch scene', project = "${workspaceFolder}",} } - - vim.cmd [[ - nnoremap ,b :DapToggleBreakpoint - nnoremap ,B :DapClearBreakpoints - nnoremap - nnoremap ,db :DapContinue - nnoremap :DapStepInto - nnoremap :DapStepOut - nnoremap :DapStepOver - ]] - end - }, - { 'dcampos/nvim-snippy', - config = function() - require'snippy'.setup{ enable_auto = true, } - vim.cmd [[ - imap '(snippy-next)' - imap '(snippy-previous)' - smap '(snippy-next)' - smap '(snippy-previous)' - xmap (snippy-cut-text) - ]] - - vim.api.nvim_create_user_command( - 'S', - function () - ---@type string - local snippets_path = vim.fn.stdpath('config') .. '/snippets/' .. vim.api.nvim_buf_get_option(0, "filetype") .. '.snippets' - - if not file_exists(snippets_path) then - local file = io.open( snippets_path, 'w' ) - assert( - file ~= nil, - ("io.open('%s', 'w') returned nil.\n"):format(snippets_path) .. - "Make sure the snippets folder in the above path exists." - ) - file:close() - print('created file: ', snippets_path) - end - - vim.api.nvim_command(('SnippyEdit %s'):format(snippets_path)) - end, - { nargs = 0 } - ) - end - }, - { 'hrsh7th/nvim-cmp', - dependencies = { - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'dcampos/nvim-snippy', - 'dcampos/cmp-snippy', - }, - config = function() - local cmp = require'cmp' - cmp.setup{ - snippet = { - expand = function(args) - require'snippy'.expand_snippet(args.body) - end, - }, - mapping = { - [''] = cmp.mapping.confirm{ select = true }, - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - }, - sources = cmp.config.sources( - { - { name = 'snippy', priority = 100000000000000000000 }, - { name = 'nvim_lsp', priority = 100}, - { name = 'path', priority = 1}, - } - ), - preselect = cmp.PreselectMode.None, - } - end, - }, } -do -- split line +do -- split line {{{1 local SPLIT_WHITESPACE = ' ' local SPLIT_DELIMETERS = { -- single characters only [','] = true,