all repos — dotfiles @ 22b436ec5d011f3e0b75fcd759576433190902de

linux dotfiles

nvim: add stuff
Prithu Goswami pg@prithu.dev
Sun, 21 Jul 2024 23:46:16 +0530
commit

22b436ec5d011f3e0b75fcd759576433190902de

parent

3fd05b5e4ece7e7978bfa3e90fd6b5ec203e9aa1

M config/nvim/init.luaconfig/nvim/init.lua

@@ -12,6 +12,8 @@

vim.opt.relativenumber = true vim.opt.mouse = 'a' +vim.g.copilot_enabled = 0 + -- vim.opt.clipboard = 'unnamedplus' vim.opt.undofile = true

@@ -94,6 +96,9 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })

vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) +vim.keymap.set('n', 'j', 'gj') +vim.keymap.set('n', 'k', 'gk') + -- tab navigation vim.keymap.set('n', 'H', 'gT') vim.keymap.set('n', 'L', 'gt')

@@ -111,6 +116,9 @@ vim.keymap.set('v', '<', '<gv')

vim.keymap.set('n', 'n', 'nzz') vim.keymap.set('n', '<C-d>', '<C-d>zz') vim.keymap.set('n', '<C-u>', '<C-u>zz') + +-- Launches +vim.keymap.set('n', '<leader>g', ':Neogit<cr>') local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then

@@ -349,6 +357,8 @@ {

'rafamadriz/friendly-snippets', config = function() require('luasnip.loaders.from_vscode').lazy_load() + + require 'snippets' end, }, },

@@ -455,6 +465,7 @@ },

sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, + { name = 'buffer' }, { name = 'path' }, }, }

@@ -492,13 +503,16 @@ -- end

-- Check out: https://github.com/echasnovski/mini.nvim end, }, - { 'nyoom-engineering/oxocarbon.nvim', - config = function() - vim.cmd.colorscheme "oxocarbon" - end }, + { + 'nyoom-engineering/oxocarbon.nvim', + config = function() + vim.cmd.colorscheme 'oxocarbon' + end, + }, require 'plugins.nvimtree', require 'plugins.neogit', require 'plugins.lint', + { 'github/copilot.vim' }, } -- Need to test
M config/nvim/lazy-lock.jsonconfig/nvim/lazy-lock.json

@@ -5,6 +5,7 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },

"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform.nvim": { "branch": "master", "commit": "cd75be867f2331b22905f47d28c0c270a69466aa" }, + "copilot.vim": { "branch": "release", "commit": "25f73977033c597d530c7ab0e211d99b60927d2d" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, "gitsigns.nvim": { "branch": "main", "commit": "e9c4187c3774a46df2d086a66cf3a7e6bea4c432" },
M config/nvim/lua/plugins/lint.luaconfig/nvim/lua/plugins/lint.lua

@@ -4,7 +4,7 @@ event = { 'BufReadPre', 'BufNewFile' },

config = function() local lint = require 'lint' lint.linters_by_ft = { - python = { 'mypy' }, + -- python = { 'mypy' }, terraform = { 'tflint' }, }
A config/nvim/lua/snippets.lua

@@ -0,0 +1,49 @@

+local snip_status_ok, ls = pcall(require, 'luasnip') +if not snip_status_ok then + return +end + +local s = ls.snippet +local fmt = require('luasnip.extras.fmt').fmt +-- local sn = ls.snippet_node +-- local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +-- local c = ls.choice_node +-- local d = ls.dynamic_node + +local get_title = function(nodes) + local url = nodes[1][1] + vim.notify('Url: ' .. url) + local out = '' + local jobid = vim.fn.jobstart({ 'fetchtitle', url }, { + stdout_buffered = true, + on_stdout = function(_, data) + if data then + print(vim.inspect(data)) + out = data[1] + end + end, + }) + vim.fn.jobwait({ jobid }, 3000) + return out +end + +ls.add_snippets('markdown', { + s( + 'mdlink', + fmt('[{}]({})', { + f(get_title, { 1 }), + i(1), + }) + ), + s( + 'll', + fmt('#### {}', { + f(function() + return os.date '%Y-%m-%d %H:%M' + end), + }) + ), +})