make neovim nix managed
This commit is contained in:
parent
6f0b34ed75
commit
5a25314924
2 changed files with 34 additions and 156 deletions
|
|
@ -1,141 +1,87 @@
|
||||||
vim.o.winborder = "rounded" -- floating windows (hover docs, pickers) get rounded borders
|
vim.o.winborder = "rounded"
|
||||||
vim.o.tabstop = 2 -- a tab character is rendered 2 columns wide
|
vim.o.tabstop = 2
|
||||||
vim.o.ignorecase = true -- searching is case insensitive
|
vim.o.ignorecase = true
|
||||||
vim.o.shiftwidth = 2 -- >> and << indent by 2
|
vim.o.shiftwidth = 2
|
||||||
vim.o.smartindent = true -- indent new lines based on the line above
|
vim.o.smartindent = true
|
||||||
vim.opt.wrap = false -- long lines run off the screen instead of wrapping
|
vim.opt.wrap = false
|
||||||
vim.opt.number = true -- show line numbers
|
vim.opt.number = true
|
||||||
vim.o.relativenumber = true -- ...but relative to the cursor, so 5j / 5k are easy to aim
|
vim.o.relativenumber = true
|
||||||
vim.o.termguicolors = true -- 24 bit color, the colorscheme needs this
|
vim.o.termguicolors = true
|
||||||
vim.o.undofile = true -- keep undo history on disk, so you can undo after reopening a file
|
vim.o.undofile = true
|
||||||
vim.o.incsearch = true -- jump to the match while you are still typing the search
|
vim.o.incsearch = true
|
||||||
vim.o.signcolumn = "yes" -- always show the left gutter (diagnostics live there) so text never jumps
|
vim.o.signcolumn = "yes"
|
||||||
vim.opt.clipboard = "unnamedplus" -- yank and paste use the system clipboard
|
vim.opt.clipboard = "unnamedplus"
|
||||||
vim.opt.expandtab = true -- pressing tab inserts spaces, not a tab character
|
vim.opt.expandtab = true
|
||||||
|
vim.g.nix_managed = true
|
||||||
|
|
||||||
-- vim.pack is neovim's built in plugin manager. it clones these repos into
|
|
||||||
-- stdpath("data")/site/pack the first time you start. `vim.pack.update()`
|
|
||||||
-- updates them.
|
|
||||||
vim.pack.add({
|
|
||||||
{ src = "https://github.com/nvim-tree/nvim-web-devicons" }, -- filetype icons (needs a nerd font in your terminal)
|
|
||||||
{ src = "https://github.com/scottmckendry/cyberdream.nvim" }, -- the colorscheme
|
|
||||||
{ src = "https://github.com/stevearc/oil.nvim" }, -- file manager that is just an editable buffer
|
|
||||||
{ src = "https://github.com/neovim/nvim-lspconfig" }, -- ready made configs for language servers
|
|
||||||
{ src = "https://github.com/saghen/blink.cmp" }, -- the autocomplete popup
|
|
||||||
{ src = "https://github.com/folke/snacks.nvim" }, -- grab bag of small tools. we use the picker, terminal and lazygit
|
|
||||||
{ src = "https://github.com/folke/todo-comments.nvim" }, -- highlights TODO/FIXME/HACK and can list them
|
|
||||||
{ src = "https://github.com/folke/trouble.nvim" }, -- a readable list of errors and warnings
|
|
||||||
{ src = "https://github.com/nvim-treesitter/nvim-treesitter" },-- real syntax parsing, better highlighting
|
|
||||||
{ src = "https://github.com/j-hui/fidget.nvim" }, -- little lsp progress spinner in the corner
|
|
||||||
{ src = "https://github.com/nvim-lualine/lualine.nvim" }, -- the statusline at the bottom
|
|
||||||
})
|
|
||||||
|
|
||||||
-- most plugins only need setup() called with no arguments to turn them on.
|
|
||||||
require("blink.cmp").setup()
|
require("blink.cmp").setup()
|
||||||
require("todo-comments").setup()
|
require("todo-comments").setup()
|
||||||
require("trouble").setup()
|
require("trouble").setup()
|
||||||
require("fidget").setup()
|
require("fidget").setup()
|
||||||
require("lualine").setup({
|
require("lualine").setup({
|
||||||
options = {
|
options = {
|
||||||
-- plain | instead of the default powerline arrows, so it looks right in any font
|
|
||||||
component_separators = { left = "|", right = "|" },
|
component_separators = { left = "|", right = "|" },
|
||||||
section_separators = { left = "|", right = "|" },
|
section_separators = { left = "|", right = "|" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
require("oil").setup({
|
require("oil").setup({
|
||||||
default_file_explorer = true, -- opening a directory opens oil instead of netrw
|
default_file_explorer = true,
|
||||||
delete_to_trash = true, -- deleting a file in oil sends it to the trash, not the void
|
delete_to_trash = true,
|
||||||
skip_confirm_for_simple_edits = true, -- don't ask "are you sure" for renames and single deletes
|
skip_confirm_for_simple_edits = true,
|
||||||
view_options = { show_hidden = true }, -- show dotfiles
|
view_options = { show_hidden = true },
|
||||||
-- oil's own keymaps, inside an oil buffer only.
|
|
||||||
keymaps = {
|
keymaps = {
|
||||||
["g?"] = { "actions.show_help", mode = "n" }, -- everything oil can do
|
["g?"] = { "actions.show_help", mode = "n" },
|
||||||
["<CR>"] = "actions.select", -- open the file/directory under the cursor
|
["<CR>"] = "actions.select",
|
||||||
["-"] = { "actions.parent", mode = "n" }, -- go up one directory
|
["-"] = { "actions.parent", mode = "n" },
|
||||||
["_"] = { "actions.open_cwd", mode = "n" }, -- jump to the directory nvim was started in
|
["_"] = { "actions.open_cwd", mode = "n" },
|
||||||
["`"] = { "actions.cd", mode = "n" }, -- make this directory nvim's working directory
|
["`"] = { "actions.cd", mode = "n" },
|
||||||
},
|
},
|
||||||
use_default_keymaps = false, -- only the five above, nothing else
|
use_default_keymaps = false,
|
||||||
})
|
})
|
||||||
require("snacks").setup({ picker = { ui_select = true } }) -- any "pick one" prompt uses the snacks picker
|
require("snacks").setup({ picker = { ui_select = true } })
|
||||||
|
|
||||||
vim.cmd("colorscheme cyberdream")
|
vim.cmd("colorscheme cyberdream")
|
||||||
|
|
||||||
-- briefly flash whatever you just yanked, so you can see what got copied
|
|
||||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank()
|
vim.highlight.on_yank()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- These are the language servers we turn on. the server programs themselves are
|
|
||||||
-- installed by nix (see programs.neovim.extraPackages in flake.nix), this line
|
|
||||||
-- only tells neovim to start them for the right filetypes.
|
|
||||||
vim.lsp.enable({ "lua_ls", "ts_ls", "rust_analyzer", "html", "cssls", "jsonls", "nixd" })
|
vim.lsp.enable({ "lua_ls", "ts_ls", "rust_analyzer", "html", "cssls", "jsonls", "nixd" })
|
||||||
|
|
||||||
-- This means that we should run the callback when the event LspAttach happens
|
|
||||||
-- aka. when a language server attaches to the buffer. that is when these
|
|
||||||
-- keymaps start doing something useful, so we only set them then.
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition) -- go to where the thing under the cursor is defined
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition)
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration) -- go to its declaration (mostly a C/C++ thing)
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration)
|
||||||
vim.keymap.set('n', 'gr', Snacks.picker.lsp_references) -- list every place it is used
|
vim.keymap.set('n', 'gr', Snacks.picker.lsp_references)
|
||||||
vim.keymap.set('n', 'gt', Snacks.picker.lsp_type_definitions) -- go to the definition of its type
|
vim.keymap.set('n', 'gt', Snacks.picker.lsp_type_definitions)
|
||||||
vim.keymap.set('n', '<leader>ss', Snacks.picker.lsp_symbols) -- search symbols in this file
|
vim.keymap.set('n', '<leader>ss', Snacks.picker.lsp_symbols)
|
||||||
vim.keymap.set('n', '<leader>sS', Snacks.picker.lsp_workspace_symbols) -- search symbols in the whole project
|
vim.keymap.set('n', '<leader>sS', Snacks.picker.lsp_workspace_symbols)
|
||||||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action) -- offer the fixes/refactors the server suggests
|
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action)
|
||||||
vim.keymap.set('n', '<leader>cr', vim.lsp.buf.rename) -- rename it everywhere at once
|
vim.keymap.set('n', '<leader>cr', vim.lsp.buf.rename)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- This is your leader key. set it to whatever you like. but space is nice i think
|
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
-- space+o in normal mode saves this file and re-runs it, so config changes apply
|
|
||||||
-- without restarting neovim. (to update the plugins themselves: :lua vim.pack.update())
|
|
||||||
vim.keymap.set('n', '<leader>o', ':update<CR>:source<CR>')
|
vim.keymap.set('n', '<leader>o', ':update<CR>:source<CR>')
|
||||||
-- space+w in normal mode writes (saves) the current buffer
|
|
||||||
vim.keymap.set('n', '<leader>w', ':write<CR>')
|
vim.keymap.set('n', '<leader>w', ':write<CR>')
|
||||||
-- space+q in normal mode quits
|
|
||||||
vim.keymap.set('n', '<leader>q', ':quit<CR>')
|
vim.keymap.set('n', '<leader>q', ':quit<CR>')
|
||||||
-- space+f in normal mode opens a file picker where you can fuzzy search for files by their name
|
|
||||||
vim.keymap.set('n', '<leader>f', function() Snacks.picker.files() end)
|
vim.keymap.set('n', '<leader>f', function() Snacks.picker.files() end)
|
||||||
-- space+sg in normal mode opens a fuzzy searcher that searches through the contents of all files
|
|
||||||
vim.keymap.set('n', '<leader>sg', function() Snacks.picker.grep() end)
|
vim.keymap.set('n', '<leader>sg', function() Snacks.picker.grep() end)
|
||||||
-- space+e in normal mode opens a new buffer with Oil. this is the file manager or what you would call it
|
|
||||||
-- The cool thing about oil is that you can edit all of your files like neovim buffers
|
|
||||||
vim.keymap.set('n', '<leader>e', ':Oil<CR>')
|
vim.keymap.set('n', '<leader>e', ':Oil<CR>')
|
||||||
|
|
||||||
-- ctrl+h/j/k/l move to the split left/down/up/right. <C-w>h is neovim's own
|
|
||||||
-- "go to the window on the left", these just put it on an easier key.
|
|
||||||
-- normal mode only: inside the terminal these keys belong to the shell
|
|
||||||
-- (ctrl+l clears it), and you leave that terminal with ctrl+t anyway.
|
|
||||||
vim.keymap.set('n', '<C-h>', '<C-w>h')
|
vim.keymap.set('n', '<C-h>', '<C-w>h')
|
||||||
vim.keymap.set('n', '<C-l>', '<C-w>l')
|
vim.keymap.set('n', '<C-l>', '<C-w>l')
|
||||||
vim.keymap.set('n', '<C-k>', '<C-w>k')
|
vim.keymap.set('n', '<C-k>', '<C-w>k')
|
||||||
vim.keymap.set('n', '<C-j>', '<C-w>j')
|
vim.keymap.set('n', '<C-j>', '<C-w>j')
|
||||||
|
|
||||||
-- ctrl+t toggles a floating zsh terminal. it works both in normal mode and from
|
|
||||||
-- inside the terminal itself, so the same key opens and closes it
|
|
||||||
vim.keymap.set({ "n", "t" }, "<C-t>", function() Snacks.terminal.toggle("zsh") end)
|
vim.keymap.set({ "n", "t" }, "<C-t>", function() Snacks.terminal.toggle("zsh") end)
|
||||||
-- space+g in normal mode opens lazygit in floating window (tui for git)
|
|
||||||
vim.keymap.set('n', '<leader>g', function() Snacks.lazygit() end)
|
vim.keymap.set('n', '<leader>g', function() Snacks.lazygit() end)
|
||||||
-- space+t in normal mode opens a picker of todo comments where you can search through them
|
|
||||||
vim.keymap.set('n', '<leader>t', function() Snacks.picker.todo_comments() end)
|
vim.keymap.set('n', '<leader>t', function() Snacks.picker.todo_comments() end)
|
||||||
-- space+x in normal mode opens a bottom bar that shows warning and errors from your LSP in the current buffer
|
|
||||||
vim.keymap.set('n', '<leader>x', ":Trouble diagnostics toggle filter.buf=0<CR>")
|
vim.keymap.set('n', '<leader>x', ":Trouble diagnostics toggle filter.buf=0<CR>")
|
||||||
-- space+shift+X does the same but for every file in the project
|
|
||||||
vim.keymap.set('n', '<leader>X', ":Trouble diagnostics<CR>")
|
vim.keymap.set('n', '<leader>X', ":Trouble diagnostics<CR>")
|
||||||
-- space+| in normal mode vertically splits the current buffer
|
|
||||||
vim.keymap.set('n', '<leader>|', ":vsplit<CR>")
|
vim.keymap.set('n', '<leader>|', ":vsplit<CR>")
|
||||||
-- space+_ in normal mode horizontally splits the current buffer
|
|
||||||
vim.keymap.set('n', '<leader>_', ":split<CR>")
|
vim.keymap.set('n', '<leader>_', ":split<CR>")
|
||||||
-- ESC in normal mode clears the highlighting left over from your last search
|
|
||||||
vim.keymap.set('n', '<ESC>', ":noh<CR>")
|
vim.keymap.set('n', '<ESC>', ":noh<CR>")
|
||||||
-- > in visual mode indents the selected lines (gv reselects them so you can keep pressing >)
|
|
||||||
vim.keymap.set("v", ">", ">gv", { silent = true, desc = "Indent and reselect" })
|
vim.keymap.set("v", ">", ">gv", { silent = true, desc = "Indent and reselect" })
|
||||||
-- < in visual mode unindents the selected lines
|
|
||||||
vim.keymap.set("v", "<", "<gv", { silent = true, desc = "Unindent and reselect" })
|
vim.keymap.set("v", "<", "<gv", { silent = true, desc = "Unindent and reselect" })
|
||||||
-- space+lf in normal mode calls the lsp's formatter on the current buffer
|
|
||||||
vim.keymap.set('n', '<leader>lf', vim.lsp.buf.format)
|
vim.keymap.set('n', '<leader>lf', vim.lsp.buf.format)
|
||||||
|
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
{
|
|
||||||
"plugins": {
|
|
||||||
"Navigator.nvim": {
|
|
||||||
"rev": "d43816089689ccffd23543bc02331e9a68f3ec2f",
|
|
||||||
"src": "https://github.com/dynamotn/Navigator.nvim"
|
|
||||||
},
|
|
||||||
"blink.cmp": {
|
|
||||||
"rev": "c573a15a62bd0bfd4006ee0849b24f5404395500",
|
|
||||||
"src": "https://github.com/saghen/blink.cmp"
|
|
||||||
},
|
|
||||||
"catppuccin": {
|
|
||||||
"rev": "e068ab5f8261f23f6f71ffd8791ae40315b77b9c",
|
|
||||||
"src": "https://github.com/catppuccin/nvim"
|
|
||||||
},
|
|
||||||
"copilot.lua": {
|
|
||||||
"rev": "ad7e729e9a6348f7da482be0271d452dbc4c8e2c",
|
|
||||||
"src": "https://github.com/zbirenbaum/copilot.lua"
|
|
||||||
},
|
|
||||||
"cyberdream.nvim": {
|
|
||||||
"rev": "39f69ebcd8de69c741bb7a65353aa37dd0680ad1",
|
|
||||||
"src": "https://github.com/scottmckendry/cyberdream.nvim"
|
|
||||||
},
|
|
||||||
"fidget.nvim": {
|
|
||||||
"rev": "889e2e96edef4e144965571d46f7a77bcc4d0ddf",
|
|
||||||
"src": "https://github.com/j-hui/fidget.nvim"
|
|
||||||
},
|
|
||||||
"lualine.nvim": {
|
|
||||||
"rev": "a905eeebc4e63fdc48b5135d3bf8aea5618fb21c",
|
|
||||||
"src": "https://github.com/nvim-lualine/lualine.nvim"
|
|
||||||
},
|
|
||||||
"nvim-lspconfig": {
|
|
||||||
"rev": "4b7fbaa239c5db6b36f424a4521ca9f1a401be33",
|
|
||||||
"src": "https://github.com/neovim/nvim-lspconfig"
|
|
||||||
},
|
|
||||||
"nvim-treesitter": {
|
|
||||||
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
|
|
||||||
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
|
|
||||||
},
|
|
||||||
"nvim-web-devicons": {
|
|
||||||
"rev": "c72328a5494b4502947a022fe69c0c47e53b6aa6",
|
|
||||||
"src": "https://github.com/nvim-tree/nvim-web-devicons"
|
|
||||||
},
|
|
||||||
"oil.nvim": {
|
|
||||||
"rev": "0fcc83805ad11cf714a949c98c605ed717e0b83e",
|
|
||||||
"src": "https://github.com/stevearc/oil.nvim"
|
|
||||||
},
|
|
||||||
"snacks.nvim": {
|
|
||||||
"rev": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e",
|
|
||||||
"src": "https://github.com/folke/snacks.nvim"
|
|
||||||
},
|
|
||||||
"todo-comments.nvim": {
|
|
||||||
"rev": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668",
|
|
||||||
"src": "https://github.com/folke/todo-comments.nvim"
|
|
||||||
},
|
|
||||||
"tree-sitter-surrealdb.nvim": {
|
|
||||||
"rev": "a875cb4be3035a0cb525c35c4c6f1512fb9fa27d",
|
|
||||||
"src": "https://github.com/dariuscorvus/tree-sitter-surrealdb.nvim"
|
|
||||||
},
|
|
||||||
"trouble.nvim": {
|
|
||||||
"rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a",
|
|
||||||
"src": "https://github.com/folke/trouble.nvim"
|
|
||||||
},
|
|
||||||
"typst-preview.nvim": {
|
|
||||||
"rev": "87db18b8d19c8b0eed399f52e4c527ce5afe4817",
|
|
||||||
"src": "https://github.com/chomosuke/typst-preview.nvim"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue