feat: misc updates to neovim config

main
Ricard Illa 2023-07-23 16:03:14 +02:00
parent 23fbc255a2
commit 60985280b3
No known key found for this signature in database
GPG Key ID: F69A672B72E54902
2 changed files with 74 additions and 22 deletions

View File

@ -8,11 +8,11 @@
vimdiffAlias = true;
withPython3 = true;
extraPackages = with pkgs; [
ansible-language-server
beancount-language-server
black
docker-compose-language-service
efm-langserver
fd
gcc
hlint
ltex-ls
@ -22,6 +22,7 @@
nixpkgs-fmt
nodePackages.dockerfile-language-server-nodejs
nodePackages.pyright
ripgrep
ruff-lsp
shellcheck
shfmt
@ -34,4 +35,5 @@
plugins = [ pkgs.vimPlugins.packer-nvim ];
extraLuaConfig = builtins.readFile ./init.lua;
};
home.packages = [ pkgs.neovide ];
}

View File

@ -1,11 +1,8 @@
-- luacheck: globals vim
require("packer").startup(function(use)
use("tpope/vim-sensible")
use("vimwiki/vimwiki")
use('nvim-tree/nvim-web-devicons')
use("freitass/todo.txt-vim")
use("ledger/vim-ledger")
use("psliwka/vim-smoothie")
@ -17,12 +14,11 @@ require("packer").startup(function(use)
-- fern
use("lambdalisue/fern.vim")
use("lambdalisue/nerdfont.vim")
use("lambdalisue/fern-renderer-nerdfont.vim")
use("lambdalisue/glyph-palette.vim")
use("lambdalisue/fern-git-status.vim")
use("lambdalisue/fern-mapping-git.vim") -- to check
use("lambdalisue/fern-hijack.vim")
use("TheLeoP/fern-renderer-web-devicons.nvim")
-- airline
use("vim-airline/vim-airline")
@ -49,7 +45,6 @@ require("packer").startup(function(use)
use("gruvbox-community/gruvbox")
-- language support
use("darrikonn/vim-gofmt")
use("Glench/Vim-Jinja2-Syntax")
use("preservim/vim-markdown")
use("LnL7/vim-nix")
@ -57,7 +52,6 @@ require("packer").startup(function(use)
use("LaTeX-Box-Team/LaTeX-Box")
use("vito-c/jq.vim")
use("tpope/vim-haml")
use({ "psf/black", branch = "stable" })
use("elzr/vim-json")
use("jpalardy/vim-slime")
@ -71,12 +65,26 @@ require("packer").startup(function(use)
use("L3MON4D3/LuaSnip") -- Snippets plugin
use("lukas-reineke/lsp-format.nvim")
use {
'nvim-telescope/telescope.nvim',
requires = { { 'nvim-lua/plenary.nvim' } }
}
use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }
use("sheerun/vim-polyglot")
use("nvim-treesitter/nvim-treesitter")
use("nvim-orgmode/orgmode")
use("akinsho/org-bullets.nvim")
use("lukas-reineke/headlines.nvim")
use("michaelb/sniprun")
use("dhruvasagar/vim-table-mode")
end)
vim.g.mapleader = ","
vim.g.maplocaleader = "\\"
local o = vim.opt
local function map(mode, shortcut, command)
@ -121,9 +129,6 @@ else
o.listchars = [[tab:> ,extends:>,precedes:<,nbsp:.,trail:_]]
end
vim.g.mapleader = ","
vim.g.maplocaleader = "\\"
o.splitbelow = true
o.splitright = true
nmap("<A-r>", "<C-w>r")
@ -176,7 +181,7 @@ vim.g.markdown_syntax_conceal = 0
o.updatetime = 100 -- to make gigutter more responsive
vim.g["fern#renderer"] = "nerdfont"
vim.g["fern#renderer"] = "nvim-web-devicons"
vim.cmd([[
function! s:init_fern() abort
nmap <buffer> T <Plug>(fern-action-open:tab)
@ -196,11 +201,8 @@ augroup my-glyph-palette
autocmd FileType nerdtree,startify call glyph_palette#apply()
augroup END
]])
nmap("<leader>t", ":Fern . -drawer -toggle<cr>")
-- nmap("<leader>f", ":Files<cr>")
nmap("<leader>rg", ":Rg<cr>")
nmap("<leader>tf", ":Fern . -drawer -toggle<cr>")
nmap("<leader><Bs>", ": cd ..<cr>")
nmap("<leader>b", ": Buffers<cr>")
vim.g["indentLine_char"] = ""
vim.g["indentLine_setConceal"] = 0
@ -234,7 +236,6 @@ lspconfig.ruff_lsp.setup { capabilities = capabilities }
lspconfig.nixd.setup { capabilities = capabilities }
lspconfig.jsonls.setup { capabilities = capabilities }
lspconfig.ansiblels.setup { capabilities = capabilities }
lspconfig.beancount.setup { capabilities = capabilities }
lspconfig.ltex.setup { capabilities = capabilities }
@ -362,8 +363,15 @@ require("nvim-treesitter.configs").setup {
}
orgmode.setup {
org_agenda_files = { "~/Nextcloud/org/*" },
org_default_notes_file = "~/Nextcloud/org/refile.org",
org_agenda_files = { "~/Nextcloud/org/agenda/*.org" },
org_default_notes_file = "~/Nextcloud/org/notes.org",
org_capture_templates = {
w = {
description = "Wishlist",
template = "* %x",
target = "~/Nextcloud/org/wishlist.org"
}
}
}
vim.api.nvim_create_autocmd("LspAttach", {
@ -372,9 +380,51 @@ vim.api.nvim_create_autocmd("LspAttach", {
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set("n", "<C-f>", function()
vim.lsp.buf.format({ async = true })
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})
local telescope_builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', telescope_builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', telescope_builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', telescope_builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', telescope_builtin.help_tags, {})
local telescope = require("telescope")
telescope.setup {
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
}
}
}
telescope.load_extension("fzf")
require'nvim-web-devicons'.setup()
if vim.g.neovide then
vim.o.guifont = "Hack Nerd Font:h10"
end