feat: Basic working config

- Added copilot
- Disabled nvim-navic (errors out when copilot-cmp is enabled)
- Added clangd
- Added packages for nvim-dap
This commit is contained in:
Jiří Štefka 2024-03-06 18:55:22 +01:00
parent e2cff543d6
commit 5a85ef99ff
Signed by: jiriks74
GPG key ID: 1D5E30D3DB2264DE
8 changed files with 61 additions and 6 deletions

View file

@ -22,10 +22,17 @@ with final.pkgs.lib; let
# ...
# }
all-plugins = with pkgs.vimPlugins; [
nvim-dap # Debuggerhttps://github.com/mfussenegger/nvim-dap
nvim-dap-ui # Debugger UI https://github.com/rcarriga/nvim-dap-ui/
# Themes
tokyonight-nvim # https://github.com/folke/tokyonight.nvim
# plugins from nixpkgs go in here.
# https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=vimPlugins
nvim-treesitter.withAllGrammars
luasnip # snippets | https://github.com/l3mon4d3/luasnip/
# nvim-cmp (autocompletion) and extensions
nvim-cmp # https://github.com/hrsh7th/nvim-cmp
cmp_luasnip # snippets autocompletion extension for nvim-cmp | https://github.com/saadparwaiz1/cmp_luasnip/
@ -37,26 +44,33 @@ with final.pkgs.lib; let
cmp-nvim-lua # neovim lua API as completion source | https://github.com/hrsh7th/cmp-nvim-lua/
cmp-cmdline # cmp command line suggestions
cmp-cmdline-history # cmp command line history suggestions
copilot-lua # Github Copilot https://github.com/zbirenbaum/copilot.lua/
copilot-cmp # Add Copilot as a cmp source # https://github.com/zbirenbaum/copilot-cmp/
# ^ nvim-cmp extensions
# git integration plugins
diffview-nvim # https://github.com/sindrets/diffview.nvim/
neogit # https://github.com/TimUntersberger/neogit/
gitsigns-nvim # https://github.com/lewis6991/gitsigns.nvim/
vim-fugitive # https://github.com/tpope/vim-fugitive/
# ^ git integration plugins
# telescope and extensions
telescope-nvim # https://github.com/nvim-telescope/telescope.nvim/
telescope-fzy-native-nvim # https://github.com/nvim-telescope/telescope-fzy-native.nvim
# telescope-smart-history-nvim # https://github.com/nvim-telescope/telescope-smart-history.nvim
# ^ telescope and extensions
# UI
lualine-nvim # Status line | https://github.com/nvim-lualine/lualine.nvim/
nvim-navic # Add LSP location to lualine | https://github.com/SmiteshP/nvim-navic
statuscol-nvim # Status column | https://github.com/luukvbaal/statuscol.nvim/
nvim-treesitter-context # nvim-treesitter-context
# ^ UI
# language support
# ^ language support
# navigation/editing enhancement plugins
vim-unimpaired # predefined ] and [ navigation keymaps | https://github.com/tpope/vim-unimpaired/
eyeliner-nvim # Highlights unique characters for f/F and t/T motions | https://github.com/jinh0/eyeliner.nvim
@ -64,15 +78,18 @@ with final.pkgs.lib; let
nvim-treesitter-textobjects # https://github.com/nvim-treesitter/nvim-treesitter-textobjects/
nvim-ts-context-commentstring # https://github.com/joosepalviste/nvim-ts-context-commentstring/
# ^ navigation/editing enhancement plugins
# Useful utilities
nvim-unception # Prevent nested neovim sessions | nvim-unception
# ^ Useful utilities
# libraries that other plugins depend on
sqlite-lua
plenary-nvim
nvim-web-devicons
vim-repeat
# ^ libraries that other plugins depend on
# bleeding-edge plugins from flake inputs
# (mkNvimPlugin inputs.wf-nvim "wf.nvim") # (example) keymap hints | https://github.com/Cassin01/wf.nvim
# ^ bleeding-edge plugins from flake inputs
@ -81,8 +98,10 @@ with final.pkgs.lib; let
extraPackages = with pkgs; [
# language servers, etc.
clang-tools
lua-language-server
nil # nix LSP
nodejs_20
];
in {
# This is the neovim derivation

18
nvim/ftplugin/c.lua Normal file
View file

@ -0,0 +1,18 @@
-- Exit if the language server isn't available
if vim.fn.executable('clangd') ~= 1 then
return
end
local root_files = {
'compile_commands.json',
'.vscode',
'.git',
}
vim.lsp.start {
name = 'clangd',
cmd = { 'clangd' },
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
capabilities = require('user.lsp').make_client_capabilities(),
-- capabilities = { offsetEncoding = "utf-8" },
}

View file

@ -99,6 +99,7 @@ vim.diagnostic.config {
g.editorconfig = true
cmd[[colorscheme tokyonight]]
vim.opt.colorcolumn = '100'
-- Native plugins

View file

@ -63,7 +63,7 @@ vim.api.nvim_create_autocmd('LspAttach', {
local client = vim.lsp.get_client_by_id(ev.data.client_id)
-- Attach plugins
require('nvim-navic').attach(client, bufnr)
-- require('nvim-navic').attach(client, bufnr)
vim.cmd.setlocal('signcolumn=yes')
vim.bo[bufnr].bufhidden = 'hide'

View file

@ -67,7 +67,7 @@ cmp.setup {
complete_with_source('path')
end
end, { 'i', 'c', 's' }),
['<C-n>'] = cmp.mapping(function(fallback)
['<C-j>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- expand_or_jumpable(): Jump outside the snippet region
@ -80,7 +80,7 @@ cmp.setup {
fallback()
end
end, { 'i', 'c', 's' }),
['<C-p>'] = cmp.mapping(function(fallback)
['<C-k>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
@ -103,6 +103,7 @@ cmp.setup {
},
sources = cmp.config.sources {
-- The insertion order influences the priority of the sources
{ name = "copilot", group_index = 2 },
{ name = 'nvim_lsp', keyword_length = 3 },
{ name = 'nvim_lsp_signature_help', keyword_length = 3 },
{ name = 'buffer' },

15
nvim/plugin/copilot.lua Normal file
View file

@ -0,0 +1,15 @@
if vim.g.did_load_copilot_plugin then
return
end
vim.g.did_load_copilot_plugin = true
-- local configs = require('copilot')
-- many plugins annoyingly require a call to a 'setup' function to be loaded,
-- even with default configs
require("copilot").setup({
suggestion = { enabled = false },
panel = { enabled = false },
})

View file

@ -3,8 +3,8 @@ if vim.g.did_load_lualine_plugin then
end
vim.g.did_load_lualine_plugin = true
local navic = require('nvim-navic')
navic.setup {}
-- local navic = require('nvim-navic')
-- avic.setup {}
---Indicators for special modes,
---@return string status
@ -32,7 +32,7 @@ require('lualine').setup {
sections = {
lualine_c = {
-- nvim-navic
{ navic.get_location, cond = navic.is_available },
-- { navic.get_location, cond = navic.is_available },
},
lualine_z = {
-- (see above)

View file

@ -6,5 +6,6 @@ vim.g.did_load_plugins_plugin = true
-- many plugins annoyingly require a call to a 'setup' function to be loaded,
-- even with default configs
require("copilot_cmp").setup()
require('nvim-surround').setup()
require('which-key').setup()