diff --git a/.editorconfig b/.editorconfig index 0c1e1d0..499eab0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,6 +13,6 @@ end_of_line = lf [*.{cmd,ps1,csv,doskey}] end_of_line = crlf -[*.{sh,yml}] +[*.{lua,sh,yml}] indent_size = 2 diff --git a/nvim/.luarc.json b/nvim/.luarc.json new file mode 100644 index 0000000..eaf7284 --- /dev/null +++ b/nvim/.luarc.json @@ -0,0 +1,4 @@ +{ + "diagnostics.globals": [ + ] +} diff --git a/nvim/init.lua b/nvim/init.lua index 3a16169..5170269 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -4,14 +4,8 @@ -- neovim standard paths: -- https://neovim.io/doc/user/starting.html#standard-path -local cmd = vim.cmd - -require('dotfiles.core.options') -require('dotfiles.core.keymaps') -require('dotfiles.lazy-nvim') - -cmd[[ colorscheme tokyonight]] --- cmd[[ colorscheme nord]] - -require('dotfiles.plugin-config') +require('options') +require('keymaps') +require('lazy-nvim') +vim.cmd[[ colorscheme tokyonight]] diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index be9634f..d08ffc2 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,17 +1,19 @@ { - "catppuccin": { "branch": "main", "commit": "5e36ca599f4aa41bdd87fbf2c5aae4397ac55074" }, - "gitsigns.nvim": { "branch": "main", "commit": "4aaacbf5e5e2218fd05eb75703fe9e0f85335803" }, - "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "catppuccin": { "branch": "main", "commit": "048c18fc531703815f5e10765ea46ce9b2c75ae4" }, + "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" }, + "mason.nvim": { "branch": "main", "commit": "9c9416817c9f4e6f333c749327a1ed5355cfab61" }, "nordtheme": { "branch": "main", "commit": "f13f5dfbb784deddbc1d8195f34dfd9ec73e2295" }, - "nvim-treesitter": { "branch": "master", "commit": "59d4c14a1a4262cf637ff2420032593afa062749" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "19a91a38b02c1c28c14e0ba468d20ae1423c39b2" }, - "nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" }, - "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" }, + "nvim-treesitter": { "branch": "master", "commit": "cd4e0909948eb33d3959e133c16f837e4db122c6" }, + "plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, - "tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" }, + "tokyonight.nvim": { "branch": "main", "commit": "67c6050e1ca41260c919236a098ba278472c7520" }, "vim-commentary": { "branch": "master", "commit": "f67e3e67ea516755005e6cccb178bc8439c6d402" }, - "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, + "vim-fugitive": { "branch": "master", "commit": "854a8df0d06b8d3fcb30fa7f2b08c62b553eee3b" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" } + "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } } \ No newline at end of file diff --git a/nvim/lua/dotfiles/core/keymaps.lua b/nvim/lua/dotfiles/core/keymaps.lua deleted file mode 100644 index af02d1c..0000000 --- a/nvim/lua/dotfiles/core/keymaps.lua +++ /dev/null @@ -1,13 +0,0 @@ --- neovim init file --- github.com/davidjenni/dotfiles - -local k = vim.keymap - -k.set('n', 'h', 'noh') -k.set('n', '', ':wincmd k') -k.set('n', '', ':wincmd j') -k.set('n', '', ':wincmd h') -k.set('n', '', ':wincmd l') - --- plugins set their own keymaps in ~/.config/nvim/lua/plugins/*.lua --- diff --git a/nvim/lua/dotfiles/plugin-config.lua b/nvim/lua/dotfiles/plugin-config.lua deleted file mode 100644 index 3271cd1..0000000 --- a/nvim/lua/dotfiles/plugin-config.lua +++ /dev/null @@ -1,69 +0,0 @@ --- neovim init file --- github.com/davidjenni/dotfiles - -require('lualine').setup() - -require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'c_sharp', 'go', 'json', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - - highlight = { enable = true }, - indent = { enable = true, disable = { 'python' } }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, -} - diff --git a/nvim/lua/dotfiles/plugins/init.lua b/nvim/lua/dotfiles/plugins/init.lua deleted file mode 100644 index 4040820..0000000 --- a/nvim/lua/dotfiles/plugins/init.lua +++ /dev/null @@ -1,17 +0,0 @@ --- neovim init file --- github.com/davidjenni/dotfiles - -return { - 'nvim-lua/plenary.nvim', - - { 'nvim-lualine/lualine.nvim', - opts = { - theme = 'auto' - } - }, - - 'tpope/vim-commentary', - 'tpope/vim-fugitive', - 'tpope/vim-surround', - 'tpope/vim-unimpaired', -} diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua new file mode 100644 index 0000000..15b6b47 --- /dev/null +++ b/nvim/lua/keymaps.lua @@ -0,0 +1,13 @@ +-- neovim init file +-- github.com/davidjenni/dotfiles + +local k = vim.keymap + +k.set('n', 'h', 'noh', { desc = 'Clear highlights' }) +k.set('n', '', ':wincmd k', { desc = 'Move to window above' }) +k.set('n', '', ':wincmd j', { desc = 'Move to window below' }) +k.set('n', '', ':wincmd h', { desc = 'Move to window left' }) +k.set('n', '', ':wincmd l', { desc = 'Move to window right' }) + +-- plugins set their own keymaps in ~/.config/nvim/lua/plugins/*.lua +-- diff --git a/nvim/lua/dotfiles/lazy-nvim.lua b/nvim/lua/lazy-nvim.lua similarity index 61% rename from nvim/lua/dotfiles/lazy-nvim.lua rename to nvim/lua/lazy-nvim.lua index 4800f3c..f6f34d6 100644 --- a/nvim/lua/dotfiles/lazy-nvim.lua +++ b/nvim/lua/lazy-nvim.lua @@ -15,5 +15,15 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) -require('lazy').setup('dotfiles.plugins') +local opts = { + -- defaults = { + -- lazy = true, + -- }, + install = { + colorscheme = { "catppuccin" }, + }, +} +-- merge and load all .lua files under lua/plugins, see: +-- https://github.com/folke/lazy.nvim#-structuring-your-plugins +require("lazy").setup("plugins", opts) diff --git a/nvim/lua/dotfiles/core/options.lua b/nvim/lua/options.lua similarity index 95% rename from nvim/lua/dotfiles/core/options.lua rename to nvim/lua/options.lua index 4e51f7d..9ff5606 100644 --- a/nvim/lua/dotfiles/core/options.lua +++ b/nvim/lua/options.lua @@ -67,3 +67,6 @@ opt.swapfile = false opt.hidden = true opt.switchbuf = 'useopen' +-- disable folding; see also `set nofoldenable` +opt.foldlevel = 99 + diff --git a/nvim/lua/plugins/basics.lua b/nvim/lua/plugins/basics.lua new file mode 100644 index 0000000..f7a14e5 --- /dev/null +++ b/nvim/lua/plugins/basics.lua @@ -0,0 +1,7 @@ + return { + 'tpope/vim-commentary', + 'tpope/vim-fugitive', + 'tpope/vim-surround', + 'tpope/vim-unimpaired', + { 'nvim-tree/nvim-web-devicons', lazy = true, }, + } diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..96ef2ce --- /dev/null +++ b/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,14 @@ +return { + 'lewis6991/gitsigns.nvim', + event = { "BufReadPre", "BufNewFile" }, + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + }, + } diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..0fc0424 --- /dev/null +++ b/nvim/lua/plugins/lsp.lua @@ -0,0 +1,51 @@ +return { + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end + }, + + { + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls" }, + }) + end + }, + + { + -- neodev needs to start before nvim-lspconfig + "folke/neodev.nvim", + config = function() + require("neodev").setup({}) + end, + }, + + { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "j-hui/fidget.nvim", + "folke/neodev.nvim", + }, + config = function() + local lspconfig = require('lspconfig') + lspconfig.lua_ls.setup({}) + + vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Show info about symbol under cursor'}) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = 'Go to definition' }) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, { desc = 'Show code actions' }) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, { desc = 'Show references' }) + end + }, + + { + "j-hui/fidget.nvim", + config = function() + require("fidget").setup({}) + end + } +} diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..1b08631 --- /dev/null +++ b/nvim/lua/plugins/lualine.lua @@ -0,0 +1,28 @@ +local config = function() + require("lualine").setup({ + options = { + theme = "auto", + globalstatus = true, + component_separators = { left = "|", right = "|" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename", "buffers" }, + lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location", '%B' }, + }, + tabline = {}, + }) +end + +return { + "nvim-lualine/lualine.nvim", + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + lazy = false, + config = config, +} diff --git a/nvim/lua/dotfiles/plugins/editor.lua b/nvim/lua/plugins/telescope.lua similarity index 66% rename from nvim/lua/dotfiles/plugins/editor.lua rename to nvim/lua/plugins/telescope.lua index 9e491f3..b70d997 100644 --- a/nvim/lua/dotfiles/plugins/editor.lua +++ b/nvim/lua/plugins/telescope.lua @@ -1,25 +1,4 @@ --- --- neovim init file --- github.com/davidjenni/dotfiles - return { - -- gitsigns: - { - 'lewis6991/gitsigns.nvim', - event = { "BufReadPre", "BufNewFile" }, - opts = { - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "" }, - topdelete = { text = "" }, - changedelete = { text = "▎" }, - untracked = { text = "▎" }, - }, - }, - }, - - -- telescope: { 'nvim-telescope/telescope.nvim', tag = '0.1.5', dependencies = { 'nvim-lua/plenary.nvim' }, @@ -53,21 +32,37 @@ return { { "sm", "Telescope marks", desc = "Jump to Mark" }, { "so", "Telescope vim_options", desc = "Options" }, { "sR", "Telescope resume", desc = "Resume" }, - } + }, }, - - -- treesitter: { - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - build = ":TSUpdate", - }, + "nvim-telescope/telescope-ui-select.nvim", + config = function() + local telescope = require("telescope") + telescope.setup({ + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown { + -- even more opts + } - -- devicons: - { - 'nvim-tree/nvim-web-devicons', - lazy = true, + -- pseudo code / specification for writing custom displays, like the one + -- for "codeactions" + -- specific_opts = { + -- [kind] = { + -- make_indexed = function(items) -> indexed_items, width, + -- make_displayer = function(widths) -> displayer + -- make_display = function(displayer) -> function(e) + -- make_ordinal = function(e) -> string + -- }, + -- -- for example to disable the custom builtin "codeactions" display + -- do the following + -- codeactions = false, + -- } + } + } + }) + + require("telescope").load_extension("ui-select") + end }, } diff --git a/nvim/lua/dotfiles/plugins/themes.lua b/nvim/lua/plugins/themes.lua similarity index 89% rename from nvim/lua/dotfiles/plugins/themes.lua rename to nvim/lua/plugins/themes.lua index 5324898..eafc8c7 100644 --- a/nvim/lua/dotfiles/plugins/themes.lua +++ b/nvim/lua/plugins/themes.lua @@ -2,11 +2,10 @@ -- github.com/davidjenni/dotfiles return { - { "folke/tokyonight.nvim", lazy = false, - opts = { style = "moon" }, + opts = { style = "light" }, }, { @@ -21,3 +20,4 @@ return { name = "nordtheme", }, } + diff --git a/nvim/lua/plugins/toggle-term.lua b/nvim/lua/plugins/toggle-term.lua new file mode 100644 index 0000000..5ad805b --- /dev/null +++ b/nvim/lua/plugins/toggle-term.lua @@ -0,0 +1,17 @@ +return { + 'akinsho/toggleterm.nvim', + version = "*", + config = function() + require("toggleterm").setup({ + size = 20, + open_mapping = [[]], + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 1, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = 'horizontal', + }) + end, +} diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..52e7d31 --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,38 @@ +return { + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, + build = ":TSUpdate", + config = function() + require('nvim-treesitter.configs').setup({ + event = { + "BufReadPre", + "BufNewFile", + }, + ensure_installed = { 'lua', 'markdown', 'vimdoc', 'vim' }, + auto_install = false, + + highlight = { enable = true }, + indent = { enable = true }, + + -- treesitter-textobjects config: + textobjects = { + select = { + enable = true, + keymaps = { + ["af"] = { query = "@function.outer", desc = "Select outer part of function" }, + ["if"] = { query = "@function.inner", desc = "Select inner part of function" }, + ["ac"] = { query = "@class.outer", desc = "Select outer part of a class region" }, + ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" }, + }, + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + ['@class.outer'] = '', -- blockwise + }, + }, + } + }) + end, +} diff --git a/nvim/lua/plugins/which-key.lua b/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..8c52794 --- /dev/null +++ b/nvim/lua/plugins/which-key.lua @@ -0,0 +1,10 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 1000 + end, + opts = { + } +}