update: removed nixcats and added based neovim config
This commit is contained in:
25
modules/home-manager/neovim/default.nix
Normal file
25
modules/home-manager/neovim/default.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
home.packages = with pkgs; [
|
||||
#utilities
|
||||
ripgrep
|
||||
|
||||
# language servers
|
||||
lua-language-server
|
||||
vtsls
|
||||
gopls
|
||||
eslint_d
|
||||
tailwindcss-language-server
|
||||
vscode-langservers-extracted
|
||||
rust-analyzer
|
||||
yaml-language-server
|
||||
haskell-language-server
|
||||
clang
|
||||
];
|
||||
home.file = {
|
||||
".config/nvim/init.lua".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dev/personal/nixos/modules/home-manager/neovim/init.lua";
|
||||
};
|
||||
}
|
||||
179
modules/home-manager/neovim/init.lua
Normal file
179
modules/home-manager/neovim/init.lua
Normal file
@@ -0,0 +1,179 @@
|
||||
-- set leader keys
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
-- highlight as you search
|
||||
vim.opt.hlsearch = true
|
||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||
|
||||
-- preview substitutions live in preview window
|
||||
vim.opt.inccommand = 'split'
|
||||
|
||||
-- prevent cursor from hitting top or bottom of screen
|
||||
vim.opt.scrolloff = 10
|
||||
|
||||
-- line numbers
|
||||
vim.wo.number = true
|
||||
vim.wo.relativenumber = true
|
||||
|
||||
-- Indent stuff
|
||||
vim.o.expandtab = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.autoindent = true
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 2
|
||||
vim.o.shiftwidth = 2
|
||||
|
||||
-- wrapped lines are visually indented
|
||||
vim.o.breakindent = true
|
||||
|
||||
-- save undo history
|
||||
vim.o.undofile = true
|
||||
|
||||
-- case insensitive search unless capitalized
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
|
||||
-- keep on signcolumn
|
||||
vim.wo.signcolumn = 'yes'
|
||||
|
||||
-- decrease update time
|
||||
vim.o.updatetime = 250
|
||||
vim.o.timeoutlen = 300
|
||||
|
||||
-- better completion experience
|
||||
vim.o.completeopt = 'menu,preview,noselect'
|
||||
|
||||
-- better term colors
|
||||
vim.o.termguicolors = true
|
||||
|
||||
-- clean up netrw
|
||||
vim.g.netrw_liststyle = 0
|
||||
vim.g.netrw_banner = 0
|
||||
|
||||
-- Basic Keymaps
|
||||
-- improves C-u and C-d by centering on scroll
|
||||
vim.keymap.set('n', '<C-u>', '<C-u>zz', { desc = 'Scroll Up' })
|
||||
vim.keymap.set('n', '<C-d>', '<C-d>zz', { desc = 'Scroll Down' })
|
||||
|
||||
-- improved search by centering on results
|
||||
vim.keymap.set('n', 'n', 'nzzzv', { desc = 'Next Search Result' })
|
||||
vim.keymap.set('n', 'N', 'Nzzzv', { desc = 'Previous Search Result' })
|
||||
|
||||
-- diagnostics
|
||||
vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||
|
||||
-- clipboard binds
|
||||
vim.keymap.set({"v", "x", "n"}, '<leader>y', '"+y', { noremap = true, silent = true, desc = 'Yank to clipboard' })
|
||||
vim.keymap.set({"n", "v", "x"}, '<leader>Y', '"+yy', { noremap = true, silent = true, desc = 'Yank line to clipboard' })
|
||||
vim.keymap.set({'n', 'v', 'x'}, '<leader>p', '"+p', { noremap = true, silent = true, desc = 'Paste from clipboard' })
|
||||
vim.keymap.set('i', '<C-p>', '<C-r><C-p>+', { noremap = true, silent = true, desc = 'Paste from clipboard from within insert mode' })
|
||||
vim.keymap.set("x", "<leader>P", '"_dP', { noremap = true, silent = true, desc = 'Paste over selection without erasing unnamed register' })
|
||||
|
||||
-- Plugins
|
||||
vim.pack.add({
|
||||
{ src = 'https://github.com/vague-theme/vague.nvim' },
|
||||
{ src = 'https://github.com/miikanissi/modus-themes.nvim' },
|
||||
{ src = 'https://github.com/nvim-treesitter/nvim-treesitter' },
|
||||
{ src = 'https://github.com/nvim-mini/mini.pick' },
|
||||
{ src = 'https://github.com/nvim-mini/mini.extra' },
|
||||
{ src = 'https://github.com/nvim-mini/mini.icons' },
|
||||
{ src = 'https://github.com/nvim-mini/mini.notify' },
|
||||
{ src = 'https://github.com/nvim-mini/mini.pairs' },
|
||||
{ src = 'https://github.com/nvim-mini/mini.surround' },
|
||||
{ src = 'https://github.com/neovim/nvim-lspconfig' },
|
||||
{ src = 'https://github.com/stevearc/oil.nvim' },
|
||||
{ src = 'https://github.com/saghen/blink.cmp', version = vim.version.range('1.*') },
|
||||
})
|
||||
|
||||
-- Theme (vague)
|
||||
vim.cmd('colorscheme modus')
|
||||
|
||||
-- Blink
|
||||
require('blink.cmp').setup({
|
||||
signature = { enabled = true }
|
||||
})
|
||||
|
||||
-- Oil
|
||||
require('oil').setup()
|
||||
|
||||
-- Mini
|
||||
require('mini.icons').setup()
|
||||
require('mini.pick').setup()
|
||||
require('mini.extra').setup()
|
||||
require('mini.notify').setup()
|
||||
require('mini.pairs').setup()
|
||||
require('mini.surround').setup()
|
||||
vim.keymap.set('n', '<leader>ff', MiniPick.builtin.files, { desc = 'Find Files' })
|
||||
vim.keymap.set('n', '<leader>fg', MiniPick.builtin.grep_live, { desc = 'Grep Files' })
|
||||
|
||||
-- Oil
|
||||
vim.keymap.set('n', '<leader>fe', '<CMD>Oil<CR>', { desc = 'Explore Files' })
|
||||
|
||||
-- LSP
|
||||
-- global on_attach
|
||||
local function lsp_on_attach(client, bufnr)
|
||||
-- utility function for LSP keymaps
|
||||
local nmap = function(keys, func, desc)
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
-- if client:supports_method('textDocument/completion') then
|
||||
-- local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
|
||||
-- client.server_capabilities.completionProvider.triggerCharacters = chars
|
||||
--
|
||||
-- vim.lsp.completion.enable(true, client.id, bufnr, {autotrigger = true})
|
||||
-- end
|
||||
|
||||
nmap('<leader>rn', vim.lsp.buf.rename, 'Rename')
|
||||
nmap('<leader>ca', vim.lsp.buf.code_action, 'Code Actions')
|
||||
nmap('gd', vim.lsp.buf.definition, 'Goto Definition')
|
||||
|
||||
nmap('gr', function() MiniExtra.pickers.lsp({ scope = 'references' }) end, 'Goto References')
|
||||
nmap('gI', function() MiniExtra.pickers.lsp({ scope = 'implementation' }) end, 'Goto Implementation')
|
||||
nmap('<leader>ds', function() MiniExtra.pickers.lsp({ scope = 'document_symbol' }) end, 'Document Symbols')
|
||||
nmap('<leader>ws', function() MiniExtra.pickers.lsp({ scope = 'workspace_symbol_live' }) end, 'Workspace Symbols')
|
||||
|
||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Goto Type Definition')
|
||||
nmap('gD', vim.lsp.buf.declaration, 'Goto Declaration')
|
||||
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
nmap('<C-K>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||
end
|
||||
|
||||
vim.lsp.config('*', {
|
||||
on_attach = lsp_on_attach
|
||||
})
|
||||
|
||||
-- Langauges
|
||||
vim.lsp.config('lua_ls', {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { 'vim' },
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.enable('lua_ls')
|
||||
vim.lsp.enable('vtsls')
|
||||
vim.lsp.enable('cssls')
|
||||
vim.lsp.enable('tailwindcss')
|
||||
vim.lsp.enable('eslint')
|
||||
vim.lsp.enable('gopls')
|
||||
vim.lsp.enable('nixd')
|
||||
vim.lsp.enable('rust_analyzer')
|
||||
vim.lsp.enable('yamlls')
|
||||
vim.lsp.enable('clangd')
|
||||
vim.lsp.enable('hls')
|
||||
Reference in New Issue
Block a user