From ea0b10f35a013d59181ec019b3d7efb18f6482f1 Mon Sep 17 00:00:00 2001 From: jimrothstein Date: Wed, 29 Nov 2023 23:21:48 -0800 Subject: [PATCH] wip --- init.lua | 5 ++ lua/jim/Nvim-R.lua | 20 +++++++ lua/jim/config.lua | 138 ++++++-------------------------------------- lua/jim/keymaps.lua | 48 ++++----------- lua/jim/options.lua | 87 ++++++++++++++++++++++++++++ 5 files changed, 143 insertions(+), 155 deletions(-) create mode 100644 lua/jim/Nvim-R.lua create mode 100644 lua/jim/options.lua diff --git a/init.lua b/init.lua index c07307bb..7182d79c 100644 --- a/init.lua +++ b/init.lua @@ -5,10 +5,15 @@ -- -- main config file 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.keymaps' -- lua/jim/keymaps.lua require 'jim.settings' -- lua/jim/settings.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 diff --git a/lua/jim/Nvim-R.lua b/lua/jim/Nvim-R.lua new file mode 100644 index 00000000..ac2a5856 --- /dev/null +++ b/lua/jim/Nvim-R.lua @@ -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 +]]) + +vim.cmd([[ autocmd FileType r nnoremap wwww ]]) +vim.cmd([[ + " autocmd BufRead, BufNewFile *.r *.qmd *.rmd setlocal filetype = r + ]]) diff --git a/lua/jim/config.lua b/lua/jim/config.lua index 66adc4a7..50c3274c 100644 --- a/lua/jim/config.lua +++ b/lua/jim/config.lua @@ -1,21 +1,21 @@ -- config.lua --- Set as the leader key --- See `:help mapleader` --- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) +-- Set = leader key ( set first; See `:help mapleader` ) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- vim.g.minisurround_disable=true --- for now turn on LIGHT -vim.cmd 'set background=light' - --- Install package manager --- https://github.com/folke/lazy.nvim --- `:help lazy.nvim.txt` for more info +-------------------------- +-- Install package manager, lazy.nvim +-------------------------- +-- 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' -- vim.fn is bridge to vimscript. and `system` is vimscript command +-- if not vim.loop.fs_stat(lazypath) then vim.fn.system { 'git', @@ -26,6 +26,7 @@ if not vim.loop.fs_stat(lazypath) then lazypath, } end + -- vim.opt is like using :set; :append or :prepend is like vimscript set+= vim.opt.rtp:prepend(lazypath) @@ -34,6 +35,7 @@ vim.opt.rtp:prepend(lazypath) -- -- You can also configure plugins after the setup call, -- as they will be available in your neovim runtime. +-- require('lazy').setup({ -- NOTE: First, some plugins that don't require any configuration @@ -46,26 +48,30 @@ require('lazy').setup({ -- Detect tabstop and shiftwidth automatically '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. -- The configuration is done below. Search for lspconfig to find it below. -- mason -- installs the lsp server -- nvim-lspconfig -- connect LSP to our setup ? { -- LSP Configuration & Plugins + -- Need BOTH nvim-lspconfig and mason? (SEE Nat Bennett blog post) 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim - { 'williamboman/mason.nvim', config = true }, + { + 'williamboman/mason.nvim', config = true }, 'williamboman/mason-lspconfig.nvim', - -- Useful status updates for LSP -- NOTE !! -- 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! '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 { 'm4xshen/hardtime.nvim', @@ -250,98 +242,6 @@ else vim.cmd [[ set background=dark]] -- acer-desktop 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 -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 (experimnetal) -vim.o.ts = 2 -- 1 is 2 characters -vim.o.sw = 0 -- don't know --- tw = maximum width of text (or 0 to disable) - --- becomes all spaces, no 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 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 ]] diff --git a/lua/jim/keymaps.lua b/lua/jim/keymaps.lua index 64562c45..a16d597d 100644 --- a/lua/jim/keymaps.lua +++ b/lua/jim/keymaps.lua @@ -1,10 +1,7 @@ ----------------------- --- EXPERIMENTS: ----------------------- --- date -vim.keymap.set({ 'i', 'v' }, ':w', ':w', - { desc = "Write File, in insert modde", silent = false }) - +-- Notes +-- keymaps vs which-key +-- which-key should pick up any separaely defined keymaps +-- to maintain groups, however, do this in which-key ---------------------- -- [[ Basic Keymaps ]] ---------------------- @@ -12,25 +9,13 @@ vim.keymap.set({ 'i', 'v' }, ':w', ':w', -- See `:help vim.keymap.set()` vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) vim.keymap.set({ 'n', 'v' }, 'q', '', { desc = "", silent = true }) - +vim.keymap.set({ 'i', 'v' }, ':w', ':w', + { desc = "Write File, in insert modde", silent = false }) -------------------------- -- EXPERIMENTAL -------------------------- -local map = vim.keymap.set --- not working -map( - "n", - "cd", - "cd! %:h", - { desc = "cd to current buffer path" } -) - --- works -map("n", "..", "cd! ..", { desc = "cd up a level" }) --------------------------- --------------------------- @@ -50,10 +35,10 @@ local telescope_home = function() require('telescope.builtin').find_files({ cwd = "/home/jim", hidden = true }) end + -- telescope - fails -- vim.keymap.set('n', ' fz', function() builtin.find_files({ cwd = '/home/jim/' }) end, {}) -vim.keymap.set('n', 'fz', telescope_home, { desc = 'Telescope file_files in home directory' }) - +vim.keymap.set('n', 'sz', telescope_home, { desc = 'Telescope file_files in home directory' }) -- vim.keymap.set( {'n', ']nc', -- Remap for dealing with word wrap @@ -116,15 +101,12 @@ local mappings = { -- checkhealth, gb, gc are conflicts q = { "q", 'Quit - no warn' }, }, - f = { - name = "find things & Telescope", + s = { + name = "find, search & Telescope", f = { "Telescope find_files", "Telescope | Find File" }, -- create a binding with label g = { "Telescope live_grep", "Telescope | Full Text Search" }, b = { "Telescope buffers", "Telescope [B]uffers" }, - -- tz is conflict - -- fails - -- - -- z = { "Telescope find_files", "Find File", desc = "Search Home", { cwd = '/home/jim' } }, -- create a binding with label + -- gb taken by comments plugin }, n = { @@ -138,16 +120,10 @@ local mappings = { --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 = "not in use", }, - q = { ":q", "Quit - no warn" }, Q = { ":wq", "Save & Quit" }, w = { ":w", "Save" }, x = { ":bdelete", "Close" }, @@ -155,8 +131,8 @@ local mappings = { z1 = { 'p', 'other window' }, z2 = { 'pAjunk', 'other window junk' }, rk = { ':RKill', 'RKill , but not guaranteed to close terminal' }, - -- use ck E = { ':e ~/.config/kickstart/init.lua', 'Edit KICKSTART config' }, ck = { ':e ~/.config/kickstart/init.lua', '[ck] Edit KICKSTART config' }, + cr = { ':e ~/.config/kickstart/lua/jim/Nvim-R.lua', '[cr] Edit Nvim-R config' }, } local opts = { prefix = '' } diff --git a/lua/jim/options.lua b/lua/jim/options.lua new file mode 100644 index 00000000..bf3a4c4d --- /dev/null +++ b/lua/jim/options.lua @@ -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 (experimnetal) +-- +-- tabstop (ts) is not what I think it is +-- It is "Number of spaces that a in the file counts for." and not what always displays on screen +vim.o.ts = 2 -- 1 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) + +-- becomes all spaces, no 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 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