telescope does not work yet

This commit is contained in:
Pim Kunis 2023-10-07 20:11:31 +02:00
parent 159f5dfe75
commit c4a50d2103
8 changed files with 239 additions and 143 deletions

View file

@ -18,7 +18,6 @@ in
packages = with pkgs; [ packages = with pkgs; [
keepassxc keepassxc
nil
moonlight-qt moonlight-qt
vlc vlc
nicotine-plus nicotine-plus
@ -29,9 +28,6 @@ in
tree tree
gimp gimp
libreoffice libreoffice
nodePackages.pyright
neofetch
gopls
]; ];
}; };
@ -43,26 +39,90 @@ in
home-manager.enable = true; home-manager.enable = true;
chromium.enable = true; chromium.enable = true;
neovim = { neovim =
let
toLua = str: "lua << EOF\n${str}\nEOF\n";
toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n";
in
{
enable = true; enable = true;
viAlias = true; viAlias = true;
vimAlias = true; vimAlias = true;
vimdiffAlias = true; vimdiffAlias = true;
defaultEditor = true;
plugins = with pkgs.vimPlugins; [ extraPackages = with pkgs; [
nvim-lspconfig luajitPackages.lua-lsp
gruvbox-nvim rnix-lsp
leap-nvim
telescope-nvim xclip
vim-commentary wl-clipboard
vim-sleuth
gitsigns-nvim
nvim-cmp
cmp-nvim-lsp
friendly-snippets
neodev-nvim
]; ];
extraLuaConfig = builtins.readFile ./neovim.lua;
plugins = with pkgs.vimPlugins; [
{
plugin = nvim-lspconfig;
config = toLuaFile ./nvim/plugin/lsp.lua;
}
{
plugin = comment-nvim;
config = toLua "require(\"Comment\").setup()";
}
{
plugin = gruvbox-nvim;
config = "colorscheme gruvbox";
}
neodev-nvim
nvim-cmp
{
plugin = nvim-cmp;
config = toLuaFile ./nvim/plugin/cmp.lua;
}
{
plugin = telescope-nvim;
config = toLuaFile ./nvim/plugin/telescope.lua;
}
telescope-fzf-native-nvim
cmp_luasnip
cmp-nvim-lsp
luasnip
friendly-snippets
lualine-nvim
nvim-web-devicons
{
plugin = (nvim-treesitter.withPlugins (p: [
p.tree-sitter-nix
p.tree-sitter-vim
p.tree-sitter-bash
p.tree-sitter-lua
p.tree-sitter-python
p.tree-sitter-json
]));
config = toLuaFile ./nvim/plugin/treesitter.lua;
}
vim-nix
# {
# plugin = vimPlugins.own-onedark-nvim;
# config = "colorscheme onedark";
# }
];
extraLuaConfig = ''
${builtins.readFile ./nvim/options.lua}
'';
}; };
alacritty = { alacritty = {

View file

@ -1,124 +0,0 @@
--[ GLOBAL ]--
vim.o.background = "dark"
vim.cmd([[colorscheme gruvbox]])
vim.g.mapleader = ";"
vim.o.signcolumn = "yes"
vim.wo.number = true
vim.wo.relativenumber = true
vim.wo.cursorline = true
--[ LSPCONFIG ]--
local on_attach = function(_, bufnr)
local bufmap = function(keys, func)
vim.keymap.set('n', keys, func, { buffer = bufnr })
end
bufmap('<leader>r', vim.lsp.buf.rename)
bufmap('<leader>a', vim.lsp.buf.code_action)
bufmap('gd', vim.lsp.buf.definition)
bufmap('gD', vim.lsp.buf.declaration)
bufmap('gI', vim.lsp.buf.implementation)
bufmap('<leader>D', vim.lsp.buf.type_definition)
bufmap('gr', require('telescope.builtin').lsp_references)
bufmap('<leader>s', require('telescope.builtin').lsp_document_symbols)
bufmap('<leader>S', require('telescope.builtin').lsp_dynamic_workspace_symbols)
bufmap('K', vim.lsp.buf.hover)
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, {})
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
require('neodev').setup()
require'lspconfig'.nil_ls.setup{ on_attach = on_attach, capabilities = capabilities }
require'lspconfig'.pyright.setup{ on_attach = on_attach, capabilities = capabilities }
require'lspconfig'.gopls.setup{ on_attach = on_attach, capabilities = capabilities }
--[ LEAP ]--
require('leap').add_default_mappings()
-- Don't remap 'x' in visual mode.
vim.keymap.del({'x', 'o'}, 'x')
vim.keymap.del({'x', 'o'}, 'X')
--[ TELESCOPE ]--
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fr', builtin.lsp_references, {})
vim.keymap.set('n', '<leader>fs', builtin.lsp_document_symbols, {})
require('telescope').setup{
pickers = {
find_files = {
theme = "dropdown"
},
live_grep = {
theme = "dropdown"
},
buffers = {
theme = "dropdown"
},
lsp_references = {
theme = "dropdown"
},
lsp_document_symbols = {
theme = "dropdown"
}
}
}
--[ COMMENTARY ]--
vim.cmd([[autocmd FileType nix setlocal commentstring=#\ %s]])
--[ GITSIGNS ]--
require("gitsigns").setup()
--[ CMP ]--
-- For snippets: look at https://github.com/vimjoyer/nvim-nix-video/blob/main/nvim/plugin/cmp.lua
local cmp = require('cmp')
cmp.setup {
mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },
},
}

19
nvim/options.lua Normal file
View file

@ -0,0 +1,19 @@
vim.g.mapleader = ';'
vim.g.maplocalleader = ';'
vim.o.clipboard = 'unnamedplus'
vim.o.number = true
-- vim.o.relativenumber = true
vim.o.signcolumn = 'yes'
vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.o.updatetime = 300
vim.o.termguicolors = true
vim.o.mouse = 'a'

46
nvim/plugin/cmp.lua Normal file
View file

@ -0,0 +1,46 @@
local cmp = require('cmp')
local luasnip = require('luasnip')
require('luasnip.loaders.from_vscode').lazy_load()
luasnip.config.setup {}
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}

48
nvim/plugin/lsp.lua Normal file
View file

@ -0,0 +1,48 @@
local on_attach = function(_, bufnr)
local bufmap = function(keys, func)
vim.keymap.set('n', keys, func, { buffer = bufnr })
end
bufmap('<leader>r', vim.lsp.buf.rename)
bufmap('<leader>a', vim.lsp.buf.code_action)
bufmap('gd', vim.lsp.buf.definition)
bufmap('gD', vim.lsp.buf.declaration)
bufmap('gI', vim.lsp.buf.implementation)
bufmap('<leader>D', vim.lsp.buf.type_definition)
bufmap('gr', require('telescope.builtin').lsp_references)
bufmap('<leader>s', require('telescope.builtin').lsp_document_symbols)
bufmap('<leader>S', require('telescope.builtin').lsp_dynamic_workspace_symbols)
bufmap('K', vim.lsp.buf.hover)
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, {})
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
require('neodev').setup()
require('lspconfig').lua_ls.setup {
on_attach = on_attach,
capabilities = capabilities,
root_dir = function()
return vim.loop.cwd()
end,
cmd = { "lua-lsp" },
settings = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
}
}
require('lspconfig').rnix.setup {
on_attach = on_attach,
capabilities = capabilities,
}

11
nvim/plugin/other.lua Normal file
View file

@ -0,0 +1,11 @@
-- Lualine
require("lualine").setup({
icons_enabled = true,
theme = 'onedark',
})
-- Colorscheme
vim.cmd("colorscheme gruvbox")
-- Comment
require("Comment").setup()

27
nvim/plugin/telescope.lua Normal file
View file

@ -0,0 +1,27 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fr', builtin.lsp_references, {})
vim.keymap.set('n', '<leader>fs', builtin.lsp_document_symbols, {})
require('telescope').setup{
pickers = {
find_files = {
theme = "dropdown"
},
live_grep = {
theme = "dropdown"
},
buffers = {
theme = "dropdown"
},
lsp_references = {
theme = "dropdown"
},
lsp_document_symbols = {
theme = "dropdown"
}
}
}

View file

@ -0,0 +1,9 @@
require('nvim-treesitter.configs').setup {
ensure_installed = {},
auto_install = false,
highlight = { enable = true },
indent = { enable = true },
}