Skip to content

Commit

Permalink
added lean
Browse files Browse the repository at this point in the history
  • Loading branch information
benbrastmckie committed Dec 21, 2024
1 parent 406e3e7 commit 9b36254
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 61 deletions.
1 change: 1 addition & 0 deletions nvim/after/ftplugin/lean.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vim.opt_local.spell = false
14 changes: 14 additions & 0 deletions nvim/lua/neotex/core/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,17 @@ function SearchWordUnderCursor()
local word = vim.fn.expand('<cword>')
require('telescope.builtin').live_grep({ default_text = word })
end

function CloseBuffer()
local current = vim.api.nvim_get_current_buf()
vim.cmd('bdelete') -- Close the current buffer

-- Get a list of all listed buffers
local buffers = vim.api.nvim_list_bufs()
for _, buf in ipairs(buffers) do
if vim.api.nvim_buf_is_loaded(buf) and vim.bo[buf].buflisted then
vim.api.nvim_set_current_buf(buf)
break
end
end
end
4 changes: 2 additions & 2 deletions nvim/lua/neotex/core/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require("neotex.core.keymaps")
require("neotex.core.options")
require("neotex.core.autocmds")
require("neotex.core.functions")
require("neotex.core.keymaps")
require("neotex.core.options")
2 changes: 2 additions & 0 deletions nvim/lua/neotex/core/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ keymap("n", "gcc", "<nop>", opts)
-- Surround
-- vim.keymap.set("v", '<C-s>', 'S', { remap = true }) -- see surround.lua

-- Terminal
vim.keymap.set("n", "<C-t>", "<cmd>Floaterminal<CR>", { remap = true })

-- Spelling
vim.keymap.set("n", "<C-s>", function()
Expand Down
1 change: 1 addition & 0 deletions nvim/lua/neotex/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local options = {
relativenumber = true, -- set relative numbered lines
numberwidth = 2, -- set number column width to 2 {default 4}
signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
fillchars = "eob: ", -- don't show tildes
cursorline = true, -- highlight the current line
-- colorcolumn = "100", -- highlight vertical colorcolumn (moved to after/python.lua)
wrap = true, -- display lines as one long line
Expand Down
57 changes: 57 additions & 0 deletions nvim/lua/neotex/deprecated/float-term.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")

local state = {
floating = {
buf = -1,
win = -1,
}
}

local function create_floating_window(opts)
opts = opts or {}
local width = opts.width or math.floor(vim.o.columns * 0.8)
local height = opts.height or math.floor(vim.o.lines * 0.8)

-- Calculate the position to center the window
local col = math.floor((vim.o.columns - width) / 2)
local row = math.floor((vim.o.lines - height) / 2)

-- Create a buffer
local buf = nil
if vim.api.nvim_buf_is_valid(opts.buf) then
buf = opts.buf
else
buf = vim.api.nvim_create_buf(false, true) -- No file, scratch buffer
end

-- Define window configuration
local win_config = {
relative = "editor",
width = width,
height = height,
col = col,
row = row,
style = "minimal", -- No borders or extra UI elements
border = "rounded",
}

-- Create the floating window
local win = vim.api.nvim_open_win(buf, true, win_config)

return { buf = buf, win = win }
end

local toggle_terminal = function()
if not vim.api.nvim_win_is_valid(state.floating.win) then
state.floating = create_floating_window { buf = state.floating.buf }
if vim.bo[state.floating.buf].buftype ~= "terminal" then
vim.cmd.terminal()
end
else
vim.api.nvim_win_hide(state.floating.win)
end
end

-- Example usage:
-- Create a floating window with default dimensions
vim.api.nvim_create_user_command("Floaterminal", toggle_terminal, {})
15 changes: 9 additions & 6 deletions nvim/lua/neotex/plugins/bufferline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ return {
options = {
mode = "buffers",
separator_style = "slant",
close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions"
close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
right_mouse_command = "bdelete! %d", -- can be a string | function | false, see "Mouse actions"
diagnostics = false, -- OR: | "nvim_lsp"
diagnostics_update_in_insert = false,
show_tab_indicators = false,
show_close_icon = false,
-- numbers = "ordinal", -- Display buffer numbers as ordinal numbers
sort_by = 'insert_after_current', -- OR: 'insert_at_end' | 'tabs' | 'extension' | 'relative_directory' | 'directory' | 'id' |
-- sort_by = function(buffer_a, buffer_b)
-- -- -- add custom logic
-- return buffer_a.ordinal < buffer_b.ordinal
-- end,
-- sort_by = 'insert_after_current', -- OR: 'insert_at_end' | 'tabs' | 'extension' | 'relative_directory' | 'directory' | 'id' |
sort_by = function(buffer_a, buffer_b)
-- add custom logic
local modified_a = vim.fn.getftime(buffer_a.path)
local modified_b = vim.fn.getftime(buffer_b.path)
return modified_a > modified_b
end,
offsets = {
{
filetype = "NvimTree",
Expand Down
63 changes: 59 additions & 4 deletions nvim/lua/neotex/plugins/lean.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,67 @@ return {
dependencies = {
'neovim/nvim-lspconfig',
'nvim-lua/plenary.nvim',
-- you also will likely want nvim-cmp or some completion engine
'hrsh7th/nvim-cmp', -- Completion engine
'hrsh7th/cmp-nvim-lsp', -- LSP source for nvim-cmp
-- 'saadparwaiz1/cmp_luasnip', -- Snippet source for nvim-cmp (optional)
'L3MON4D3/LuaSnip', -- Snippet engine (optional)
},

-- see details below for full configuration options
-- Configuration options for lean.nvim
opts = {
lsp = {},
mappings = true,
}
abbreviations = {
enabled = false
},
-- -- For notifications
-- stderr = {
-- enable = true,
-- on_lines = function(lines) vim.notify(lines) end
-- },
mappings = true, -- Enable default key mappings
infoview = {
autoopen = true,
}
},

-- Configuration function to set up lean.nvim and related settings
config = function(_, opts)
-- Initialize lean.nvim with the provided options
require('lean').setup(opts)

-- Prevent Infoview Buffer from Appearing in Buffer Lists
vim.api.nvim_create_autocmd("FileType", {
pattern = "leaninfo", -- Infoview buffer filetype
callback = function()
-- Set buffer options to exclude it from buffer lists and normal operations
vim.bo.buflisted = false -- Exclude from buffer lists
vim.bo.bufhidden = "hide" -- Hide the buffer when it's no longer displayed
vim.bo.buftype = "nofile" -- Specify that it's not associated with a file
-- Optional: Prevent modifications to the Infoview buffer
vim.bo.modifiable = false
vim.bo.swapfile = false
end,
group = vim.api.nvim_create_augroup("LeanInfoViewSettings", { clear = true }),
})

-- Create an augroup for Lean-related autocommands
local lean_group = vim.api.nvim_create_augroup("LeanCloseInfoview", { clear = true })

-- Define the autocommand to close Infoview on BufDelete for Lean files
vim.api.nvim_create_autocmd("BufDelete", {
group = lean_group,
pattern = "*.lean", -- Adjust the pattern if your Lean files have different extensions
callback = function()
-- Attempt to require the lean.infoview module safely
local ok, infoview = pcall(require, "lean.infoview")
if ok and infoview and infoview.close then
infoview.close()
else
-- Optional: Print a warning if the Infoview module isn't available
vim.notify("Failed to close Lean Infoview: lean.infoview module not found", vim.log.levels.WARN)
end
end,
})

end
}
16 changes: 0 additions & 16 deletions nvim/lua/neotex/plugins/lsp/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@ return {
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end

-- -- configure html server
-- lspconfig["html"].setup({
-- capabilities = default,
-- })

-- -- configure typescript server with plugin
-- lspconfig["tsserver"].setup({
-- capabilities = default,
-- })

-- -- configure emmet language server
-- lspconfig["emmet_ls"].setup({
-- capabilities = default,
-- filetypes = { "html", "typescriptreact", "javascriptreact" }, -- , "css", "sass", "scss", "less", "svelte"
-- })

-- configure python server
lspconfig["pyright"].setup({
capabilities = default,
Expand Down
31 changes: 1 addition & 30 deletions nvim/lua/neotex/plugins/toggleterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,9 @@ return {
background = "Normal",
},
},
-- on_create = fun(t: Terminal), -- function to run when the terminal is first created
-- on_open = fun(t: Terminal), -- function to run when the terminal opens
-- on_close = fun(t: Terminal), -- function to run when the terminal closes
-- on_stdout = fun(t: Terminal, job: number, data: string[], name: string) -- callback for processing output on stdout
-- on_stderr = fun(t: Terminal, job: number, data: string[], name: string) -- callback for processing output on stderr
-- on_exit = fun(t: Terminal, job: number, exit_code: number, name: string) -- function to run when terminal process exits
-- shade_filetypes = {},
-- autochdir = false, -- when neovim changes it current directory the terminal will change it's own when next it's opened
-- highlights = {
-- -- highlights which map to a highlight group name and a table of it's values
-- -- NOTE: this is only a subset of values, any group placed here will be set for the terminal window split
-- Normal = {
-- guibg = "<VALUE-HERE>",
-- },
-- NormalFloat = {
-- link = 'Normal'
-- },
-- FloatBorder = {
-- guifg = "<VALUE-HERE>",
-- guibg = "<VALUE-HERE>",
-- },
-- },
terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals
persist_mode = false, -- if set to true (default) the previous terminal mode will be remembered
persist_mode = true, -- if set to true (default) the previous terminal mode will be remembered
auto_scroll = true, -- automatically scroll to the bottom on terminal output
-- This field is only relevant if direction is set to 'float'
-- winbar = {
-- enabled = false,
-- name_formatter = function(term) -- term: Terminal
-- return term.name
-- end
-- },
}
end
}
23 changes: 20 additions & 3 deletions nvim/lua/neotex/plugins/which-key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ return {
c = { "<cmd>vert sb<CR>", "create split" },
-- k = { "<cmd>clo<CR>", "kill split" },
d = { "<cmd>update! | bdelete!<CR>", "delete buffer" },
-- d = { ":lua CloseBuffer()<CR>", "delete buffer" },
e = { "<cmd>NvimTreeToggle<CR>", "explorer" },
j = { "<cmd>clo<CR>", "drop split" },
-- h = { "<cmd>Alpha<CR>", "home" },
Expand All @@ -98,25 +99,27 @@ return {
a = { "<cmd>lua PdfAnnots()<CR>", "annotate" },
b = { "<cmd>terminal bibexport -o %:p:r.bib %:p:r.aux<CR>", "bib export" },
c = { "<cmd>:VimtexClearCache All<CR>", "clear vimtex" },
e = { "<cmd>e ~/.config/nvim/snippets/tex.snippets<CR>", "edit snippets" },
e = { "<cmd>VimtexErrors<CR>", "error report" },
f = { "<cmd>lua vim.lsp.buf.format()<CR>", "format" },
g = { "<cmd>e ~/.config/nvim/templates/Glossary.tex<CR>", "edit glossary" },
-- h = { "<cmd>lua _HTOP_TOGGLE()<CR>", "htop" },
h = { "<cmd>LocalHighlightToggle<CR>", "highlight" },
k = { "<cmd>VimtexClean<CR>", "kill aux" },
l = { "<cmd>LeanInfoviewToggle<CR>", "lean info" },
-- l = { "<cmd>lua vim.g.cmptoggle = not vim.g.cmptoggle<CR>", "LSP" },
-- m = { "<cmd>MarkdownPreview<CR>", "markdown preview" },

m = { "<cmd>TermExec cmd='python3 /home/benjamin/Documents/Philosophy/Projects/ModelChecker/Code/src/model_checker %:p:r.py'<CR>", "model checker" },
p = { "<cmd>TermExec cmd='python %:p:r.py'<CR>", "python" },
r = { "<cmd>VimtexErrors<CR>", "report errors" },
r = { "<cmd>AutolistRecalculate<CR>", "reorder list" },
t = { "<cmd>terminal latexindent -w %:p:r.tex<CR>", "tex format" },
u = { "<cmd>cd %:p:h<CR>", "update cwd" },
v = { "<plug>(vimtex-context-menu)", "vimtex menu" },
w = { "<cmd>VimtexCountWords!<CR>", "word count" },
-- w = { "<cmd>TermExec cmd='pandoc %:p -o %:p:r.docx'<CR>" , "word"},
-- s = { "<cmd>lua function() require('cmp_vimtex.search').search_menu() end<CR>" , "search citations" },
s = { "<cmd>TermExec cmd='ssh [email protected]'<CR>", "ssh" },
s = { "<cmd>e ~/.config/nvim/snippets/tex.snippets<CR>", "snippets edit" },
S = { "<cmd>TermExec cmd='ssh [email protected]'<CR>", "ssh" },
},
f = {
name = "FIND",
Expand Down Expand Up @@ -226,6 +229,20 @@ return {
v = { "<cmd>TermExec cmd='zathura %:p:r.pdf &' open=0<CR>", "view" },
-- x = { "<cmd>echo "run: unoconv -f pdf path-to.docx"" , "word to pdf"},
},
r = {
name = "RUN",
d = { "function() vim.diagnostic.open_float(0, { scope = 'line', header = false, focus = false }) end", "diagnostics" },
l = { "vim.diagnostics.setloclist", "locate errors" },
n = { "function() vim.diagnostic.goto_next{popup_opts = {show_header = false}} end", "next" },
p = { "function() vim.diagnostic.goto_prev{popup_opts = {show_header = false}} end", "prev" },
-- map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>')
-- map('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>')
-- map('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
-- map('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>')
-- map('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
-- map('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>')
-- map('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>')prev{popup_opts = {show_header = false}} end", "previous" },
},
s = {
name = "SURROUND",
s = { "<Plug>(nvim-surround-normal)", "surround" },
Expand Down

0 comments on commit 9b36254

Please sign in to comment.