This commit is contained in:
jimrothstein 2023-11-29 23:21:48 -08:00
parent 0ab3664bec
commit ea0b10f35a
5 changed files with 143 additions and 155 deletions

View File

@ -5,10 +5,15 @@
-- --
-- main config file -- main config file
require 'jim.config' -- lua/jim/config.lua require 'jim.config' -- lua/jim/config.lua
require 'jim.options' -- lua/jim/options.lua, basic neovim opts
require 'jim.cmp' -- lua/jim/cmp.lua require 'jim.cmp' -- lua/jim/cmp.lua
require 'jim.keymaps' -- lua/jim/keymaps.lua require 'jim.keymaps' -- lua/jim/keymaps.lua
require 'jim.settings' -- lua/jim/settings.lua require 'jim.settings' -- lua/jim/settings.lua
require 'jim.luasnip' -- lua/jim/luasnip.lua require 'jim.luasnip' -- lua/jim/luasnip.lua
require 'jim.Nvim-R' -- lua/jim/Nvim-R.lua
--
-- installed plugins here:
-- ~/.local/share/kickstart/lazy/
-- --
--------------------- ---------------------
-- other config files -- other config files

20
lua/jim/Nvim-R.lua Normal file
View File

@ -0,0 +1,20 @@
-- [[ Nvim-R ]]
vim.cmd([[ let R_args= ['--no-save', '--quiet'] ]]) -- minimize startup
vim.cmd([[ let R_assign=2 ]]) -- underline becomes left arrow
vim.cmd([[ let R_enable_comment=1 ]]) -- toggle comments with xx
-- seems to work
vim.cmd([[ let R_filetypes = ['r', 'rmd', 'rrst', 'rnoweb', 'quarto', 'rhelp'] ]])
vim.cmd([[let g:LanguageClient_serverCommands = {
\ 'r': ['R', '--slave', '-e', 'languageserver::run()'],
\ }
]])
vim.cmd([[
" autocmd FileType r x :RStop<CR>
]])
vim.cmd([[ autocmd FileType r nnoremap <leader>wwww <Nop> ]])
vim.cmd([[
" autocmd BufRead, BufNewFile *.r *.qmd *.rmd setlocal filetype = r
]])

View File

@ -1,21 +1,21 @@
-- config.lua -- config.lua
-- Set <space> as the leader key -- Set <space> = leader key ( set first; See `:help mapleader` )
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' ' vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- vim.g.minisurround_disable=true -- vim.g.minisurround_disable=true
-- for now turn on LIGHT --------------------------
vim.cmd 'set background=light' -- Install package manager, lazy.nvim
--------------------------
-- Install package manager -- https://github.com/folke/lazy.nvim, `:help lazy.nvim.txt` for more info
-- https://github.com/folke/lazy.nvim --
-- `:help lazy.nvim.txt` for more info -- stdpath is vimscript; vim.fn says call vimscript from inside lua
-- :echo stdpath("data") to see
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
-- vim.fn is bridge to vimscript. and `system` is vimscript command -- vim.fn is bridge to vimscript. and `system` is vimscript command
--
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system { vim.fn.system {
'git', 'git',
@ -26,6 +26,7 @@ if not vim.loop.fs_stat(lazypath) then
lazypath, lazypath,
} }
end end
-- vim.opt is like using :set; :append or :prepend is like vimscript set+= -- vim.opt is like using :set; :append or :prepend is like vimscript set+=
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
@ -34,6 +35,7 @@ vim.opt.rtp:prepend(lazypath)
-- --
-- You can also configure plugins after the setup call, -- You can also configure plugins after the setup call,
-- as they will be available in your neovim runtime. -- as they will be available in your neovim runtime.
--
require('lazy').setup({ require('lazy').setup({
-- NOTE: First, some plugins that don't require any configuration -- NOTE: First, some plugins that don't require any configuration
@ -46,26 +48,30 @@ require('lazy').setup({
-- Detect tabstop and shiftwidth automatically -- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth', 'tpope/vim-sleuth',
-- add gruvbox, must setup 1st; in options.lua set colorscheme.
{ 'ellisonleao/gruvbox.nvim' },
-- NOTE: This is where your plugins related to LSP can be installed. -- NOTE: This is where your plugins related to LSP can be installed.
-- The configuration is done below. Search for lspconfig to find it below. -- The configuration is done below. Search for lspconfig to find it below.
-- mason -- installs the lsp server -- mason -- installs the lsp server
-- nvim-lspconfig -- connect LSP to our setup ? -- nvim-lspconfig -- connect LSP to our setup ?
{ {
-- LSP Configuration & Plugins -- LSP Configuration & Plugins
-- Need BOTH nvim-lspconfig and mason? (SEE Nat Bennett blog post)
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
-- Automatically install LSPs to stdpath for neovim -- Automatically install LSPs to stdpath for neovim
{ 'williamboman/mason.nvim', config = true }, {
'williamboman/mason.nvim', config = true },
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP -- Useful status updates for LSP
-- NOTE !! -- NOTE !!
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
-- Additional lua configuration, makes nvim stuff amazing! -- Additional lua configuration, makes nvim stuff amazing!
'folke/neodev.nvim', 'folke/neodev.nvim',
}, }, -- end dependencies
}, },
{ {
@ -108,20 +114,6 @@ require('lazy').setup({
}, },
}, },
-- add gruvbox
{ 'ellisonleao/gruvbox.nvim' },
-- Configure LazyVim to load gruvbox
--
--
{
'LazyVim/LazyVim',
opts = {
colorscheme = 'gruvbox',
},
},
-- hardtime.nvim (nvim advice?) 2023-09-03 -- hardtime.nvim (nvim advice?) 2023-09-03
{ {
'm4xshen/hardtime.nvim', 'm4xshen/hardtime.nvim',
@ -250,98 +242,6 @@ else
vim.cmd [[ set background=dark]] -- acer-desktop vim.cmd [[ set background=dark]] -- acer-desktop
end end
-- [[ Nvim-R ]]
vim.cmd([[ let R_args= ['--no-save', '--quiet'] ]]) -- minimize startup
vim.cmd([[ let R_assign=2 ]]) -- underline becomes left arrow
vim.cmd([[ let R_enable_comment=1 ]]) -- toggle comments with xx
vim.cmd([[let g:LanguageClient_serverCommands = {
\ 'r': ['R', '--slave', '-e', 'languageserver::run()'],
\ }
]])
-- 2023-11-03 (experimental filetype)
vim.cmd([[
autocmd BufRead, BufNewFile *.r *.qmd *.rmd setlocal filetype = r
]])
--[[
2023-10-07 another try with R & LSP
1) Mason to install r language server (takes a while)
2) Add code below, let g:LanguageClient ... this is <https://github.com/autozimu/LanguageClient-neovim>
3) no errors, Lsp works for *.R !
BUT, can not get r language server to fire up with *.qmd
Add to bottom of *.qmd, *.R file:
# /* vim: set filetype=r : */
# vim:linebreak:nospell:nowrap:cul tw=78 fo=tqlnrc foldcolumn=1 cc=+1 filetype=r
--nope \ 'qmd': ['R', '--slave', '-e', 'languageserver::run()'],
-- compare to lua version: https://github.com/neovim/nvim-lspconfig/blob/1028360e0f2f724d93e876df3d22f63c1acd6ff9/lua/lspconfig/server_configurations/r_language_server.lua#L8
--]]
--
-- :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"
-- Set highlight on search
vim.o.hlsearch = false
-- Make line numbers default
vim.wo.number = true
vim.wo.relativenumber = true
vim.wo.foldmethod = "manual" -- cleaner vs "marker"
vim.wo.foldcolumn = '1' -- can be '0-9' (string)
-- Enable mouse mode
vim.o.mouse = 'a'
-- Sync clipboard between OS and Neovim.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.o.clipboard = 'unnamedplus'
-- Enable break indent
vim.o.breakindent = true
-- Hitting <TAB> (experimnetal)
vim.o.ts = 2 -- 1 <TAB> is 2 characters
vim.o.sw = 0 -- don't know
-- tw = maximum width of text (or 0 to disable)
-- <TAB> becomes all spaces, no <TAB> ch
vim.o.expandtab = true
-- don't break within a word
vim.o.linebreak = false
-- Save undo history
vim.o.undofile = true
-- Case-insensitive searching UNLESS \C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
-- Keep signcolumn on by default
vim.wo.signcolumn = 'yes'
-- Decrease update time
vim.o.updatetime = 250
vim.o.timeoutlen = 300 -- time mapping waits for next char
vim.o.ttimeoutlen = 10 -- time <ESC> delays before registers
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- NOTE: You should make sure your terminal supports this (yes: 2023-09-03)
vim.o.termguicolors = true
-- [[ Highlight on yank ]] -- [[ Highlight on yank ]]

View File

@ -1,10 +1,7 @@
---------------------- -- Notes
-- EXPERIMENTS: -- keymaps vs which-key
---------------------- -- which-key should pick up any separaely defined keymaps
-- date -- to maintain groups, however, do this in which-key
vim.keymap.set({ 'i', 'v' }, ':w<CR>', '<esc>:w<CR>',
{ desc = "Write File, in insert modde", silent = false })
---------------------- ----------------------
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
---------------------- ----------------------
@ -12,25 +9,13 @@ vim.keymap.set({ 'i', 'v' }, ':w<CR>', '<esc>:w<CR>',
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
vim.keymap.set({ 'n', 'v' }, 'q', '<Nop>', { desc = "<nop>", silent = true }) vim.keymap.set({ 'n', 'v' }, 'q', '<Nop>', { desc = "<nop>", silent = true })
vim.keymap.set({ 'i', 'v' }, ':w<CR>', '<esc>:w<CR>',
{ desc = "Write File, in insert modde", silent = false })
-------------------------- --------------------------
-- EXPERIMENTAL -- EXPERIMENTAL
-------------------------- --------------------------
local map = vim.keymap.set
-- not working
map(
"n",
"<Leader>cd",
"<Cmd>cd! %:h<CR>",
{ desc = "cd to current buffer path" }
)
-- works
map("n", "<Leader>..", "<Cmd>cd! ..<CR>", { desc = "cd up a level" })
--------------------------
--------------------------
@ -50,10 +35,10 @@ local telescope_home = function()
require('telescope.builtin').find_files({ cwd = "/home/jim", hidden = true }) require('telescope.builtin').find_files({ cwd = "/home/jim", hidden = true })
end end
-- telescope - fails -- telescope - fails
-- vim.keymap.set('n', '<leader > fz', function() builtin.find_files({ cwd = '/home/jim/' }) end, {}) -- vim.keymap.set('n', '<leader > fz', function() builtin.find_files({ cwd = '/home/jim/' }) end, {})
vim.keymap.set('n', '<leader>fz', telescope_home, { desc = 'Telescope file_files in home directory' }) vim.keymap.set('n', '<leader>sz', telescope_home, { desc = 'Telescope file_files in home directory' })
-- vim.keymap.set( {'n', '<leader>]nc', -- vim.keymap.set( {'n', '<leader>]nc',
-- Remap for dealing with word wrap -- Remap for dealing with word wrap
@ -116,15 +101,12 @@ local mappings = {
-- checkhealth, gb, gc are conflicts -- checkhealth, gb, gc are conflicts
q = { "<cmd>q<cr>", 'Quit - no warn' }, q = { "<cmd>q<cr>", 'Quit - no warn' },
}, },
f = { s = {
name = "find things & Telescope", name = "find, search & Telescope",
f = { "<cmd>Telescope find_files<cr>", "Telescope | Find File" }, -- create a binding with label f = { "<cmd>Telescope find_files<cr>", "Telescope | Find File" }, -- create a binding with label
g = { "<cmd>Telescope live_grep<cr>", "Telescope | Full Text Search" }, g = { "<cmd>Telescope live_grep<cr>", "Telescope | Full Text Search" },
b = { "<cmd>Telescope buffers<cr>", "Telescope [B]uffers" }, b = { "<cmd>Telescope buffers<cr>", "Telescope [B]uffers" },
-- tz is conflict
-- fails
--
-- z = { "<cmd>Telescope find_files<cr>", "Find File", desc = "Search Home", { cwd = '/home/jim' } }, -- create a binding with label
-- gb taken by comments plugin -- gb taken by comments plugin
}, },
n = { n = {
@ -138,16 +120,10 @@ local mappings = {
--vim.keymap.set('n', '<leader>tn', ':e ~/code/docs/tech_notes/300_tech_notes.qmd<CR>', { desc = 'Tech Notes' }) --vim.keymap.set('n', '<leader>tn', ':e ~/code/docs/tech_notes/300_tech_notes.qmd<CR>', { desc = 'Tech Notes' })
--vim.keymap.set('n', '<leader>mln', ':e ~/code/docs/tech_notes/500_ML_Notes.qmd<CR>', { desc = 'ML Notes' }) --vim.keymap.set('n', '<leader>mln', ':e ~/code/docs/tech_notes/500_ML_Notes.qmd<CR>', { desc = 'ML Notes' })
}, },
r = {
name = "extra R cmds",
sx = { "<cmd>RStop<CR>", "interrupt R, RStop" },
x = { "<cmd>RStop<CR>", "interrupt R, RStop" },
},
t = { t = {
name = "not in use", name = "not in use",
}, },
q = { ":q<cr>", "Quit - no warn" },
Q = { ":wq<cr>", "Save & Quit" }, Q = { ":wq<cr>", "Save & Quit" },
w = { ":w<cr>", "Save" }, w = { ":w<cr>", "Save" },
x = { ":bdelete<cr>", "Close" }, x = { ":bdelete<cr>", "Close" },
@ -155,8 +131,8 @@ local mappings = {
z1 = { '<C-W>p', 'other window' }, z1 = { '<C-W>p', 'other window' },
z2 = { '<C-W>pAjunk<esc>', 'other window junk' }, z2 = { '<C-W>pAjunk<esc>', 'other window junk' },
rk = { ':RKill<CR>', 'RKill , but not guaranteed to close terminal' }, rk = { ':RKill<CR>', 'RKill , but not guaranteed to close terminal' },
-- use <leader>ck E = { ':e ~/.config/kickstart/init.lua<cr>', 'Edit KICKSTART config' },
ck = { ':e ~/.config/kickstart/init.lua<cr>', '[ck] Edit KICKSTART config' }, ck = { ':e ~/.config/kickstart/init.lua<cr>', '[ck] Edit KICKSTART config' },
cr = { ':e ~/.config/kickstart/lua/jim/Nvim-R.lua<cr>', '[cr] Edit Nvim-R config' },
} }
local opts = { prefix = '<leader>' } local opts = { prefix = '<leader>' }

87
lua/jim/options.lua Normal file
View File

@ -0,0 +1,87 @@
-- options.lua
-- ../../init.lua
-- plugins: ~/.local/share/kickstart/lazy/
--
-- TODO
-- options: use vim.go, vim.wo, vim.bo (ie scope)
-- variables use vim.g, vim.w, vim.b ...
vim.cmd 'set background=light'
vim.cmd("colorscheme gruvbox") -- be sure installed in config
-- :h 'fo'
-- where does line belong?
-- +r comments will be autoadded
vim.cmd([[ set formatoptions+=r]])
-- scrolloff = 999, means cursor line is fixed, in center of screen
-- to always display top/bottom 8 lines, set scrolloff=8
-- global options
vim.g.scrolloff = 999
vim.g.colorcolumn = "80"
-- Set highlight on search
vim.o.hlsearch = false
-- Make line numbers default
vim.wo.number = true
vim.wo.relativenumber = true
vim.wo.foldmethod = "manual" -- cleaner vs "marker"
vim.wo.foldcolumn = '1' -- can be '0-9' (string)
-- Enable mouse mode
vim.o.mouse = 'a'
-- Sync clipboard between OS and Neovim.
-- See `:help 'clipboard'`
vim.o.clipboard = 'unnamedplus'
-- Enable break indent (windows)
vim.w.breakindent = true
-- Hitting <TAB> (experimnetal)
--
-- tabstop (ts) is not what I think it is <TAB>
-- It is "Number of spaces that a <Tab> in the file counts for." and not what always displays on screen
vim.o.ts = 2 -- 1 <TAB> is 2 characters
-- in doubt? sw and expandtab are important ones
-- shiftwidth (sw) refers to number of spaces when using >> or <<
vim.o.sw = 2
-- tw = maximum width of text (or 0 to disable)
-- <TAB> becomes all spaces, no <TAB> ch
vim.o.expandtab = true
-- don't break within a word
vim.o.linebreak = false
--
-- inccommand: usage :%s/vim/nvim will open horiz split; show only lines to be changed
vim.o.inccommand = "split"
-- Save undo history
vim.o.undofile = true
-- Case-insensitive (1) searching UNLESS \C or capital in search
-- (2) Plugins: built-in begin with lower case; 3rd party begin with Upper case
-- normally, must use :Telescope, now :telescope works
vim.o.ignorecase = true
vim.o.smartcase = true
-- Keep signcolumn on by default
vim.wo.signcolumn = 'yes'
-- Decrease update time
vim.o.updatetime = 250
vim.o.timeoutlen = 300 -- time mapping waits for next char
vim.o.ttimeoutlen = 10 -- time <ESC> delays before registers
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- NOTE: You should make sure your terminal supports this (yes: 2023-09-03)
-- gives full color range, in otherwise old technology: terminals
vim.o.termguicolors = true