/ nvim / init.lua
init.lua
  1  local g = vim.g
  2  local o = vim.o
  3  
  4  vim.g.cord_defer_startup = true
  5  
  6  -- cmd('syntax on')
  7  vim.api.nvim_command('filetype plugin indent on')
  8  
  9  vim.opt.termguicolors = true
 10  
 11  -- o.background = 'dark'
 12  
 13  -- Do not save when switching buffers
 14  -- o.hidden = true
 15  -- Decrease update time
 16  o.timeoutlen = 500
 17  o.updatetime = 200
 18  
 19  -- Number of screen lines to keep above and below the cursor
 20  o.scrolloff = 8
 21  
 22  -- Better editor UI
 23  o.number = true
 24  o.numberwidth = 5
 25  o.relativenumber = true
 26  o.signcolumn = "yes:2"
 27  -- o.cursorline = true
 28  
 29  -- Better editing experience
 30  o.expandtab = true
 31  -- o.smarttab = true
 32  o.cindent = true
 33  -- o.autoindent = true
 34  o.wrap = true
 35  -- o.textwidth = 300
 36  o.tabstop = 2
 37  o.shiftwidth = 0
 38  o.softtabstop = -1 -- If negative, shiftwidth value is used
 39  -- o.list = true
 40  -- o.listchars = 'trail:·,nbsp:◇,tab:→ ,extends:▸,precedes:◂'
 41  -- o.listchars = 'eol:¬,space:·,lead: ,trail:·,nbsp:◇,tab:→-,extends:▸,precedes:◂,multispace:···⬝,leadmultispace:│   ,'
 42  -- o.formatoptions = 'qrn1'
 43  
 44  -- Makes neovim and host OS clipboard play nicely with each other
 45  o.clipboard = "unnamedplus"
 46  
 47  -- Case insensitive searching UNLESS /C or capital in search
 48  o.ignorecase = true
 49  o.smartcase = true
 50  
 51  -- Undo and backup options
 52  o.backup = false
 53  o.writebackup = false
 54  o.undofile = true
 55  o.swapfile = false
 56  -- o.backupdir = '/tmp/'
 57  -- o.directory = '/tmp/'
 58  -- o.undodir = '/tmp/'
 59  
 60  -- Remember 50 items in commandline history
 61  o.history = 50
 62  
 63  -- Better buffer splitting
 64  o.splitright = true
 65  o.splitbelow = true
 66  
 67  -- Preserve view while jumping
 68  o.jumpoptions = "view"
 69  -- Stable buffer content on window open/close events.
 70  o.splitkeep = "screen"
 71  
 72  -- Improve diff
 73  vim.opt.diffopt:append("linematch:60")
 74  
 75  -- Smooth scrolling
 76  o.smoothscroll = true
 77  
 78  -- WARN: this won't update the search count after pressing `n` or `N`
 79  -- When running macros and regexes on a large file, lazy redraw tells neovim/vim not to draw the screen
 80  -- o.lazyredraw = true
 81  
 82  -- Better folds (don't fold by default)
 83  -- o.foldmethod = 'indent'
 84  -- o.foldlevelstart = 99
 85  -- o.foldnestmax = 3
 86  -- o.foldminlines = 1
 87  
 88  -- Map <leader> to space
 89  g.mapleader = " "
 90  g.maplocalleader = " "
 91  
 92  vim.opt.hlsearch = false
 93  vim.opt.incsearch = true
 94  
 95  local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
 96  if not vim.loop.fs_stat(lazypath) then
 97    vim.fn.system({
 98      "git",
 99      "clone",
100      "--filter=blob:none",
101      "https://github.com/folke/lazy.nvim.git",
102      "--branch=stable", -- latest stable release
103      lazypath,
104    })
105  end
106  vim.opt.rtp:prepend(lazypath)
107  require("lazy").setup({
108    spec = {
109      { import = "plugins" },
110    }
111  })
112  
113  vim.cmd 'packadd termdebug'
114  
115  local current_os = vim.loop.os_uname().sysname
116  if current_os == 'Linux' then
117    vim.g.termdebugger = 'gdb'
118  end
119  
120  local function debug_in_tab()
121    local path = vim.fn.input('path: ', '', 'file')
122    vim.cmd('Termdebug ' .. path)
123    vim.cmd 'Program'
124    local buf = vim.api.nvim_get_current_buf()
125    vim.cmd.tabnew()
126    vim.api.nvim_set_current_buf(buf)
127    vim.cmd.tabprevious()
128    vim.cmd 'Program'
129    vim.cmd.wincmd 'c'
130  end
131  
132  vim.api.nvim_create_user_command('DebugInTab', debug_in_tab, {})
133  
134  vim.keymap.set('n', '<leader>dt', function() vim.cmd 'DebugInTab' end)
135  vim.keymap.set('n', '<leader>dD', function() vim.cmd 'Debug' end)
136  vim.keymap.set('n', '<leader>db', function() vim.cmd 'Break' end)
137  vim.keymap.set('n', '<leader>do', function() vim.cmd 'Over' end)
138  vim.keymap.set('n', '<leader>ds', function() vim.cmd 'Step' end)
139  vim.keymap.set('n', '<leader>dS', function() vim.cmd 'Stop' end)
140  
141  require('cord').setup {
142    buttons = {
143      { label = "GitHub", url = "https://github.com/yourusername" },
144      { label = "Docs",   url = "https://yourdocs.example.com" }
145    }
146  }
147  
148  -- require('cord').setup {
149  --   {
150  --     display = {
151  --       theme = 'default',
152  --       flavor = 'dark',
153  --       view = 'full',
154  --       swap_fields = false,
155  --       swap_icons = false,
156  --     },
157  --     idle = {
158  --       enabled = true,
159  --       timeout = 300000,
160  --       show_status = true,
161  --       ignore_focus = true,
162  --       unidle_on_focus = true,
163  --       smart_idle = true,
164  --       details = 'Idling',
165  --       state = nil,
166  --       tooltip = '💤',
167  --       icon = nil,
168  --     },
169  --     text = {
170  --       default = nil,
171  --       workspace = function(opts) return 'In ' .. opts.workspace end,
172  --       viewing = function(opts) return 'Viewing ' .. opts.filename end,
173  --       editing = function(opts) return 'Editing ' .. opts.filename end,
174  --       file_browser = function(opts) return 'Browsing files in ' .. opts.name end,
175  --       plugin_manager = function(opts) return 'Managing plugins in ' .. opts.name end,
176  --       lsp = function(opts) return 'Configuring LSP in ' .. opts.name end,
177  --       docs = function(opts) return 'Reading ' .. opts.name end,
178  --       vcs = function(opts) return 'Committing changes in ' .. opts.name end,
179  --       notes = function(opts) return 'Taking notes in ' .. opts.name end,
180  --       debug = function(opts) return 'Debugging in ' .. opts.name end,
181  --       test = function(opts) return 'Testing in ' .. opts.name end,
182  --       diagnostics = function(opts) return 'Fixing problems in ' .. opts.name end,
183  --       games = function(opts) return 'Playing ' .. opts.name end,
184  --       terminal = function(opts) return 'Running commands in ' .. opts.name end,
185  --       dashboard = 'Home',
186  --     },
187  --     assets = nil,
188  --     variables = nil,
189  --     hooks = {
190  --       ready = nil,
191  --       shutdown = nil,
192  --       pre_activity = nil,
193  --       post_activity = nil,
194  --       idle_enter = nil,
195  --       idle_leave = nil,
196  --       workspace_change = nil,
197  --       buf_enter = nil,
198  --     },
199  --     plugins = nil,
200  --     advanced = {
201  --       workspace = {
202  --         root_markers = {
203  --           '.git',
204  --           '.hg',
205  --           '.svn',
206  --         },
207  --         limit_to_cwd = false,
208  --       },
209  --     },
210  --     buttons = {
211  --       {
212  --         label = "View Repository",
213  --         url = "https://example.com"
214  --       }
215  --     }
216  --
217  --   },
218  --
219  -- }