Skip to content

Commit

Permalink
neovim: cleanup structure
Browse files Browse the repository at this point in the history
  • Loading branch information
appaquet committed Jan 17, 2025
1 parent bde213d commit 4c670eb
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 81 deletions.
2 changes: 1 addition & 1 deletion README.nvim.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@

## Commands
* `Rename <file name>` to rename current file
* `Edit <file name>` to create a file in current buffer dir
* `New <file name>` to create a file in current buffer dir
* `Delete` to delete current file

36 changes: 36 additions & 0 deletions home-manager/modules/neovim/conf/ai.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

-----------
-- copilot
-- https://github.com/zbirenbaum/copilot.lua
require("copilot").setup({
suggestion = { enabled = false }, -- because we use cmp
panel = { enabled = false }, -- because we use cmp

filetypes = {
-- overrides defaults
markdown = true,
yaml = true,
}
})

-- https://github.com/zbirenbaum/copilot-cmp
require("copilot_cmp").setup {
method = "getCompletionsCycling",
}


-----------
--- avante
--- https://github.com/yetone/avante.nvim
require('avante_lib').load()
require('avante').setup ({
-- From https://github.com/yetone/avante.nvim/blob/main/lua/avante/config.lua
provider = "copilot",
auto_suggestions_provider = "copilot",
})

-- needed for avante
require('render-markdown').setup ({
file_types = { "markdown", "Avante" },
})

7 changes: 7 additions & 0 deletions home-manager/modules/neovim/conf/base.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

-- disable netrw file explorer (because we use nvimt-ree)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

-- set termguicolors to enable highlight groups
vim.opt.termguicolors = true

-- Load a plugin only when opening a file pattern for the first time
function load_plugin_on_first_open(plugin_name, ft, setup_fn)
local loaded = false
Expand Down
19 changes: 2 additions & 17 deletions home-manager/modules/neovim/conf/base.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Misc settings
""
syntax on
filetype plugin on

set backspace=2
set ruler " show the ruler
set showmatch " show matching brackets/parenthesis
set incsearch " find as you type search
Expand All @@ -18,26 +15,14 @@ set hidden " buffer switching without saving

set autoread " auto reread modified file
set autoindent " indent at the same level of the previous line
set mouse=a " automatically enable mouse usage
set timeoutlen=500 " time to wait for a key code sequence to complete

set exrc " allow project specific .vimrc
set secure " (https://andrew.stwrt.ca/posts/project-specific-vimrc/)
set textwidth=100 " max line length, because we aren't on a mainframe anymore

"" Persists the undo across sessions
set undodir=~/.config/nvim/undodir
set undofile

"" Fixes slow escape in tmux
"" https://www.reddit.com/r/neovim/comments/35h1g1/neovim_slow_to_respond_after_esc/
if !has('gui_running')
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif

" Defaults to space indentation
set expandtab shiftwidth=2 tabstop=2

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ local function trouble_open()
Trouble.open("diagnostics")
end

local function trouble_focus()
if Trouble.is_open("diagnostics") then
Trouble.focus()
else
Trouble.open("diagnostics")
end
end

local function trouble_close()
Trouble.close("diagnostics")
end
Expand Down Expand Up @@ -42,4 +50,5 @@ vim.keymap.set('n', '<leader>dp', trouble_prev, { desc = "Diag: Go to previous d
vim.keymap.set('n', '[d', trouble_prev, { desc = "Diag: Go to previous diagnostic" })
vim.keymap.set('n', '<leader>dl', vim.diagnostic.setloclist, { desc = "Diag: Set location list" })
vim.keymap.set('n', '<leader>do', trouble_open, { desc = "Diag: Open trouble" })
vim.keymap.set('n', '<leader>df', trouble_focus, { desc = "Diag: Focus trouble" })
vim.keymap.set('n', '<leader>dq', trouble_close, { desc = "Diag: Close trouble" })
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-- From https://github.com/jkearse3/dotfiles/blob/e3e53bb0c11daeb33dc5b44609ff46da9dd05b1c/nvim/lua/lazy_plugins/search.lua#L2

-------------
-- fzf-lua
-- From https://github.com/jkearse3/dotfiles/blob/e3e53bb0c11daeb33dc5b44609ff46da9dd05b1c/nvim/lua/lazy_plugins/search.lua#L2
local fzf = require('fzf-lua')

fzf.setup({
Expand Down Expand Up @@ -58,3 +60,8 @@ vim.keymap.set("n", "<leader>fgB", fzf.git_blame, { desc = "FZF: Git blame" })
vim.keymap.set("n", "<leader>fgt", fzf.git_tags, { desc = "FZF: Git tags" })

vim.keymap.set("n", "<leader>fdb", fzf.dap_breakpoints, { desc = "FZF: DAP breakpoints" })





File renamed without changes.
4 changes: 2 additions & 2 deletions home-manager/modules/neovim/conf/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ vim.keymap.set('n', '<Leader>w', ':BufDel<CR>', { silent = true, desc = "Close c
vim.keymap.set('n', '<Leader>wo', ':BufDelOthers<CR>', { silent = true, desc = "Close other buffers" })
vim.keymap.set('n', '<Leader>wa', ':BufDelAll<CR>', { silent = true, desc = "Close all buffers" })


-- Clipboard operations
vim.keymap.set('v', '<Leader>y', ':w !pbcopy<CR><CR>', { desc = "Copy current file content to system clipboard" })
vim.keymap.set('n', '<Leader>p', ':read !pbpaste<CR>', { desc = "Paste from system clipboard" })

-- Save & quit shortcuts
vim.keymap.set('n', '<D-s>', ':w<CR>', { silent = true, desc = "Save file (Cmd+S)" })
vim.keymap.set('n', '<Leader>s', ':w<CR>', { silent = true, desc = "Save file (Leader+S)" })
vim.keymap.set('n', '<Leader>s', ':w<CR>', { silent = true, desc = "Save file" })
vim.keymap.set('n', '<Leader>qq', ':q<CR>', { silent = true, desc = "Quit current buffer" })
vim.keymap.set('n', '<Leader>qa', ':qa<CR>', { silent = true, desc = "Quit all buffers" })

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@


-------------
--- nvim-tree
-- empty setup using defaults
require("nvim-tree").setup {
update_focused_file = {
enable = true,
},
diagnostics = {
enable = true,
show_on_dirs = true,
},
}

vim.keymap.set('n', '<Leader>e', ':NvimTreeToggle<CR>', { desc = "Tree: Toggle" })


---------------
--- bufferline
require("bufferline").setup {
options = {
show_duplicate_prefix = true,
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
text_align = "center",
separator = true,
}
},
},
}

------------
--- lualine
require('lualine').setup {
options = {
icons_enabled = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,24 @@ load_plugin_on_first_open("go", "go", function()
gofmt = 'gofmt',
}
end)


------------
-- Rust
-- https://github.com/mrcjkb/rustaceanvim#gear-advanced-configuration
-- https://github.com/mrcjkb/rustaceanvim/blob/master/lua/rustaceanvim/config/internal.lua
-- See :h rustaceanvim
vim.g.rustaceanvim = {
tools = {
},
server = {
on_attach = function(client, bufnr)
end,
default_settings = {
['rust-analyzer'] = {
},
},
},
dap = {
},
}
10 changes: 0 additions & 10 deletions home-manager/modules/neovim/conf/plugin.avante.lua

This file was deleted.

1 change: 0 additions & 1 deletion home-manager/modules/neovim/conf/plugin.bufferline.lua

This file was deleted.

17 changes: 0 additions & 17 deletions home-manager/modules/neovim/conf/plugin.copilot.lua

This file was deleted.

20 changes: 0 additions & 20 deletions home-manager/modules/neovim/conf/plugin.nvimtree.lua

This file was deleted.

22 changes: 10 additions & 12 deletions home-manager/modules/neovim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,17 @@ in
(builtins.readFile ./conf/base.vim)
(readLuaFile ./conf/base.lua)
(readLuaFile ./conf/keymap.lua)
(readLuaFile ./conf/layout.lua)
(readLuaFile ./conf/theme.lua)
(readLuaFile ./conf/plugin.autosession.lua)
(readLuaFile ./conf/plugin.avante.lua)
(readLuaFile ./conf/plugin.bufferline.lua)
(readLuaFile ./conf/plugin.copilot.lua)
(readLuaFile ./conf/plugin.fzf.lua)
(readLuaFile ./conf/plugin.lsp.lua)
(readLuaFile ./conf/plugin.lualine.lua)
(readLuaFile ./conf/plugin.neotest.lua)
(readLuaFile ./conf/plugin.nvimtree.lua)
(readLuaFile ./conf/plugin.todocomments.lua)
(readLuaFile ./conf/plugin.treesitter.lua)
(readLuaFile ./conf/plugin.trouble.lua)
(readLuaFile ./conf/sessions.lua)
(readLuaFile ./conf/fzf.lua)
(readLuaFile ./conf/diag.lua)
(readLuaFile ./conf/ai.lua)
(readLuaFile ./conf/lsp.lua)
(readLuaFile ./conf/treesitter.lua)
(readLuaFile ./conf/testing.lua)
(readLuaFile ./conf/git.lua)
(readLuaFile ./conf/code.lua)
]
);
};
Expand Down

0 comments on commit 4c670eb

Please sign in to comment.