diff --git a/init.lua b/init.lua index da46b168..3e9a70d0 100644 --- a/init.lua +++ b/init.lua @@ -8,7 +8,7 @@ require 'jim.config' -- lua/jim/config.lua require 'jim.keymaps' -- lua/jim/keymaps.lua require 'jim.settings' -- lua/jim/settings.lua require 'jim.luasnip' -- lua/jim/luasnip.lua - +-- --------------------- -- other config files --------------------- diff --git a/lua/jim/config.lua b/lua/jim/config.lua index 8330087c..4f9a3763 100644 --- a/lua/jim/config.lua +++ b/lua/jim/config.lua @@ -180,8 +180,12 @@ require('lazy').setup({ event = "BufReadPre", }, - -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, + ------------------- + -- Comments.nvim + ------------------- + -- 2023-11-12 Comment.nvim keymaps conflict with my Telescope keymaps + -- { 'numToStr/Comment.nvim', opts = {} }, + -- Fuzzy Finder (files, lsp, etc) { @@ -277,6 +281,12 @@ Add to bottom of *.qmd, *.R file: --]] -- + +-- :h 'fo' +-- where does line belong? +-- +r comments will be autoadded +vim.cmd([[ set formatoptions+=r]]) + -- always display top/bottom 8 lines vim.opt.scrolloff = 8 vim.opt.colorcolumn = "80" @@ -603,11 +613,12 @@ mason_lspconfig.setup_handlers { end, } - -- nvim-cmp configuration -- [[ Configure hrsh7th nvim-cmp ]] -- See `:help cmp` local cmp = require 'cmp' +local luasnip = require 'luasnip' +local ls = require 'luasnip' cmp.setup { snippet = { @@ -625,16 +636,21 @@ cmp.setup { behavior = cmp.ConfirmBehavior.Replace, select = true, }, + + --------------------------------------- + -- TJ says don't use this way + --------------------------------------- + -- -- TAB selects NEXT item (CR to complete) - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), + -- [''] = cmp.mapping(function(fallback) + -- if cmp.visible() then + -- cmp.select_next_item() + -- elseif luasnip.expand_or_locally_jumpable() then + -- luasnip.expand_or_jump() + -- else + -- fallback() + -- end + -- end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() diff --git a/lua/jim/keymaps.lua b/lua/jim/keymaps.lua index e9ea73c5..9a786ebc 100644 --- a/lua/jim/keymaps.lua +++ b/lua/jim/keymaps.lua @@ -1,3 +1,10 @@ +---------------------- +-- EXPERIMENTS: +---------------------- +-- date +vim.keymap.set({ 'i', 'v' }, ':w', ':w', + { desc = "Write File, in insert modde", silent = false }) + ---------------------- -- [[ Basic Keymaps ]] ---------------------- @@ -7,6 +14,7 @@ vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) vim.keymap.set({ 'n', 'v' }, 'q', '', { desc = "", silent = true }) + -------------------------- -- EXPERIMENTAL -------------------------- @@ -98,18 +106,26 @@ local mappings = { -- checkhealth, gb, gc are conflicts f = { "Telescope find_files", "Find File" }, -- create a binding with label g = { "Telescope live_grep", "Full Text Search" }, - b = { "Telescope buffers", "Buffers" }, + -- gb taken by comments plugin + bu = { "Telescope buffers", "Telescope [Bu]ffers" }, q = { "q", 'Quit - no warn' }, }, n = { name = "my notes", - t = { "e ~/code/docs/tech_notes/300_tech_notes.qmd", "[T]ech [Notes]" }, - m = { "e ~/code/docs/tech_notes/500_ML_Notes.qmd", "[M]L [Notes]" }, a = { "cd ~/code/docs/ALZ/", "cd [A]LZ [Notes]" }, - + m = { "e ~/code/docs/tech_notes/500_ML_Notes.qmd", "[M]L [Notes]" }, + h = { "e ~/code/docs/health_notes/medical_notes.qmd", + "[H]ealth [Notes]" }, + o = { "cd ~/code/docs/misc_files/", "cd Misc Notes" }, + t = { "e ~/code/docs/tech_notes/300_tech_notes.qmd", "[T]ech [Notes]" }, --vim.keymap.set('n', 'tn', ':e ~/code/docs/tech_notes/300_tech_notes.qmd', { desc = 'Tech Notes' }) --vim.keymap.set('n', 'mln', ':e ~/code/docs/tech_notes/500_ML_Notes.qmd', { desc = 'ML Notes' }) }, + r = { + name = "extra R cmds", + sx = { "RStop", "interrupt R, RStop" }, + x = { "RStop", "interrupt R, RStop" }, + }, t = { name = "telescope", f = { "Telescope find_files", "Find File" }, -- create a binding with label diff --git a/lua/jim/luasnip.lua b/lua/jim/luasnip.lua index d3baf6e6..cffee279 100644 --- a/lua/jim/luasnip.lua +++ b/lua/jim/luasnip.lua @@ -8,10 +8,20 @@ local isn = ls.indent_snippet_node local t = ls.text_node local f = ls.function_node -- HELPER -local filename = function() +-- :p expand to full path +-- :h head (last path component removed) +-- :t tail (last path component only) +-- :r root (one extension removed) +-- :e extension only +-- :lua print(vim.fn.expand '%:t') -- actual file only +local full_filename = function() return { vim.fn.expand '%:p' } end +local filename = function() + return { vim.fn.expand '%:t' } +end + -- SNIPS ls.add_snippets('all', { -- `all` all filetypes, `lua` only lua ft s('luaxx', { t 'this is lua file!' }), @@ -25,6 +35,13 @@ ls.add_snippets('all', { -- `all` all filetypes, `lua` only lua ft }, { f(filename, {}), }), + s({ + trig = "long filename", + namr = "long Filename", + dscr = "insert canonical file name", + }, { + f(full_filename, {}), + }), }) --------------- -- next line: allows use of snippet collection in vscode (??)