159 lines
4.8 KiB
Nix
159 lines
4.8 KiB
Nix
pkgs: {
|
|
enable = true;
|
|
extraConfig = ''
|
|
set tabstop=4
|
|
set softtabstop=4 " enables backspacing, etc
|
|
set shiftwidth=4
|
|
set expandtab
|
|
set tw=80
|
|
|
|
set bs=2 " allow backspacing over everything in insert mode
|
|
set ai " always set autoindenting on
|
|
|
|
set number relativenumber
|
|
set colorcolumn=100
|
|
|
|
let g:pymode_options_max_line_length=95
|
|
|
|
let mapleader = ','
|
|
map <leader>n :lnext<CR>
|
|
map <leader>p :lprev<CR>
|
|
|
|
" Find files using Telescope command-line sugar.
|
|
nnoremap <leader>e <cmd>Telescope find_files<cr>
|
|
nnoremap <leader>g <cmd>Telescope live_grep<cr>
|
|
nnoremap <leader>b <cmd>Telescope buffers<cr>
|
|
nnoremap <leader>h <cmd>Telescope help_tags<cr>
|
|
" temporary fix for broken popup menu colors
|
|
" see here: https://github.com/nvim-telescope/telescope.nvim/issues/2145
|
|
hi NormalFloat ctermfg=LightGrey
|
|
|
|
" trouble.nvim settings
|
|
nnoremap <leader>xx <cmd>TroubleToggle<cr>
|
|
nnoremap <leader>xw <cmd>TroubleToggle workspace_diagnostics<cr>
|
|
nnoremap <leader>xd <cmd>TroubleToggle document_diagnostics<cr>
|
|
nnoremap <leader>xq <cmd>TroubleToggle quickfix<cr>
|
|
nnoremap <leader>xl <cmd>TroubleToggle loclist<cr>
|
|
nnoremap gR <cmd>TroubleToggle lsp_references<cr>
|
|
|
|
lua << EOF
|
|
require 'lspconfig'
|
|
|
|
-- rust setup from https://sharksforarms.dev/posts/neovim-rust/
|
|
-- Set completeopt to have a better completion experience
|
|
-- :help completeopt
|
|
-- menuone: popup even when there's only one match
|
|
-- noinsert: Do not insert text until a selection is made
|
|
-- noselect: Do not auto-select, nvim-cmp plugin will handle this for us.
|
|
vim.o.completeopt = "menuone,noinsert,noselect"
|
|
|
|
-- Avoid showing extra messages when using completion
|
|
vim.opt.shortmess = vim.opt.shortmess + "c"
|
|
|
|
local function on_attach(client, buffer)
|
|
-- This callback is called when the LSP is atttached/enabled for this buffer
|
|
-- we could set keymaps related to LSP, etc here.
|
|
end
|
|
|
|
-- Configure LSP through rust-tools.nvim plugin.
|
|
-- rust-tools will configure and enable certain LSP features for us.
|
|
-- See https://github.com/simrat39/rust-tools.nvim#configuration
|
|
local opts = {
|
|
tools = {
|
|
runnables = {
|
|
use_telescope = true,
|
|
},
|
|
inlay_hints = {
|
|
auto = true,
|
|
show_parameter_hints = true,
|
|
parameter_hints_prefix = "",
|
|
other_hints_prefix = "",
|
|
},
|
|
virt_text = {{"demo", "IncSearch"}},
|
|
virt_text_pos = 'overlay',
|
|
},
|
|
|
|
-- all the opts to send to nvim-lspconfig
|
|
-- these override the defaults set by rust-tools.nvim
|
|
-- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer
|
|
server = {
|
|
-- on_attach is a callback called when the language server attachs to the buffer
|
|
on_attach = on_attach,
|
|
settings = {
|
|
-- to enable rust-analyzer settings visit:
|
|
-- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc
|
|
["rust-analyzer"] = {
|
|
-- enable clippy on save
|
|
checkOnSave = {
|
|
command = "clippy",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
require("rust-tools").setup(opts)
|
|
|
|
-- Setup Completion
|
|
-- See https://github.com/hrsh7th/nvim-cmp#basic-configuration
|
|
local cmp = require("cmp")
|
|
cmp.setup({
|
|
preselect = cmp.PreselectMode.None,
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["vsnip#anonymous"](args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
|
-- Add tab support
|
|
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
|
["<Tab>"] = cmp.mapping.select_next_item(),
|
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
["<C-e>"] = cmp.mapping.close(),
|
|
["<CR>"] = cmp.mapping.confirm({
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
select = true,
|
|
}),
|
|
},
|
|
|
|
-- Installed sources
|
|
sources = {
|
|
{ name = "nvim_lsp" },
|
|
{ name = "vsnip" },
|
|
{ name = "path" },
|
|
{ name = "buffer" },
|
|
},
|
|
})
|
|
EOF
|
|
'';
|
|
plugins = with pkgs.vimPlugins; [
|
|
#context-vim
|
|
#ctrlp
|
|
#fzf
|
|
#gundo
|
|
python-mode
|
|
telescope-nvim
|
|
telescope-fzf-native-nvim
|
|
#nvim-treesitter
|
|
vim-nix
|
|
|
|
# rust stuff
|
|
nvim-lspconfig
|
|
nvim-cmp
|
|
cmp-nvim-lsp
|
|
cmp-vsnip
|
|
cmp-path
|
|
cmp-buffer
|
|
vim-vsnip
|
|
rust-tools-nvim
|
|
trouble-nvim
|
|
nvim-web-devicons
|
|
];
|
|
vimAlias = true;
|
|
withPython3 = true;
|
|
}
|