Skip to content

Commit

Permalink
feat: newovim from kickstarter (#44)
Browse files Browse the repository at this point in the history
* feat: newovim from kickstarter

* fix: stylua.toml

* feat: add commenta.api plugin

* term plug

* feat: beautify cofnig

* feat: add term and small fixes

* feat: keymap and linter

* feat: lazygit and floating temr with hotkeys

* fix: lsp_fabllback

* feat: go formaters

* feat: fix hotkeys

* feat: foldering

* feat: foldering

* fix: setup file

* feat: comment in visual mode, small setvim opt

* feat: add moving line hotkeys

* feat: autopairs

* feat: add C moving in inster mode

* feat: update

* feat: fix formating

* feat: add trouble plugin

* fix: global settings

* feat: colorizer

* fix: set

* chore: hotkeys desc

* feat: add golang autoimport and gofumpt setting by default

* feat: fix keymaping and add global search

* fix: change terminal

* feat: lazygit

* fix: indent_line and add bg to kitty

* fix: go to definition

* feat: add timeout in which-key

* fix: move to one palce
  • Loading branch information
senelway authored Oct 19, 2023
1 parent 4fc45b1 commit f7b0ad5
Show file tree
Hide file tree
Showing 66 changed files with 911 additions and 2,415 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ configstore
simple-update-notifier
.github
nvim/db_ui
old_nvim
lazy-lock.json
3 changes: 3 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"workspace.checkThirdParty": false
}
4 changes: 2 additions & 2 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
column_width = 120
column_width = 300
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
quote_style = "AutoPreferSingle"
call_parentheses = "None"
3 changes: 2 additions & 1 deletion kitty/kitty.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,8 @@ disable_ligatures never
#: this option when reloading the config will only work if
#: dynamic_background_opacity was enabled in the original config.

# background_image none
background_image ./kitty_bg.png
background_image_layout scaled

#: Path to a background image. Must be in PNG format.

Expand Down
Binary file added kitty/kitty_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions nvim/.stylua.toml

This file was deleted.

84 changes: 0 additions & 84 deletions nvim/README.md
Original file line number Diff line number Diff line change
@@ -1,84 +0,0 @@
## Install

```sh
brew install neovim
brew install ripgrep # is required for grep searching with Telescope (OPTIONAL).

git clone [email protected]:senelway/dotfiles.git ~/.config/_tmp
cd ~/.config/_tmp
mv nvim ../nvim
```

## Uninstall

```sh
rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim
rm -rf ~/.cache/nvim
```

## Configuration

```sh
cd ~/.config/nvim/lua/custom/
# configs/overrides.lu there is a custom config for plugins which includes in configs/plugins.lua
# mappings.lua there is a custom hotkeys
```

## All Hotkeys

```sh
## <leader>ch
```

## Plugins | Mason update

```sh
sudo nvim

:Lazy update
:Lazy sync

:MasonInstallAll
:TSInstall vue tsx go
```

## Plugins list

- [Custom](https://github.com/senelway/dotfiles/blob/main/nvim/lua/custom/plugins.lua)
- [Base](https://github.com/senelway/dotfiles/blob/main/nvim/lua/plugins/init.lua)

## Spellcheck

```sh
:set spelllang=en_us,cjk
## [s go to prev spell error
## ]s go to next spell error
```

## Copilot

```sh
# use this command for auth
:Copilot auth

## accpet suggestion
## Control + v
## <C+v>

## config in ~/.config/nvim/lua/custom/plugins.lua
```

## Terminal

<details>
<summary>ITerm2</summary>

> we could not recommend to use iterm2, better to use [kitty](https://github.com/kovidgoyal/kitty) or [alacritty](https://github.com/alacritty/alacritty) instead
```sh
## color preset for iterm (better with recats theme in neovim)
## https://github.com/catppuccin/iterm/blob/main/colors/catppuccin-mocha.itermcolors
```

</details>
47 changes: 32 additions & 15 deletions nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
require "core"
require 'config.set'
require 'config.keymap'

local custom_init_path = vim.api.nvim_get_runtime_file("lua/custom/init.lua", false)[1]

if custom_init_path then
dofile(custom_init_path)
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
}
end

require("core.utils").load_mappings()
vim.opt.rtp:prepend(lazypath)

local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
require('lazy').setup(require 'plugins.setup', {})

-- bootstrap lazy.nvim!
if not vim.loop.fs_stat(lazypath) then
require("core.bootstrap").gen_chadrc_template()
require("core.bootstrap").lazy(lazypath)
end

dofile(vim.g.base46_cache .. "defaults")
vim.opt.rtp:prepend(lazypath)
require "plugins"
require 'config.telescope'

vim.defer_fn(function()
require 'config.treesitter'
end, 0)

require('mason').setup()
require('mason-lspconfig').setup()

require('neodev').setup()

require 'config.lspconfig'
require 'config.cmp'

require 'config.which_key'
---
require 'tools.github'
require 'tools.yank'
39 changes: 0 additions & 39 deletions nvim/lazy-lock.json

This file was deleted.

45 changes: 45 additions & 0 deletions nvim/lua/config/cmp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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' },
},
}
38 changes: 38 additions & 0 deletions nvim/lua/config/keymap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

-- spliting
vim.keymap.set('n', '\\', ':vsplit<CR>', { desc = 'Vertical split' })
vim.keymap.set('n', '|', ':split<CR>', { desc = 'Horizontal split' })

-- basic movement
vim.keymap.set('n', '<C-j>', '<C-w>j', { desc = 'Move down' })
vim.keymap.set('n', '<C-k>', '<C-w>k', { desc = 'Move up' })
vim.keymap.set('n', '<C-l>', '<C-w>l', { desc = 'Move right' })
vim.keymap.set('n', '<C-h>', '<C-w>h', { desc = 'Move left' })
vim.keymap.set('n', '<C-q>', '<C-w>q', { desc = 'Close' })
vim.keymap.set('n', '<leader>e', ':Explore<CR>', { noremap = true, silent = true, desc = '[E]xplorer' })
vim.keymap.set('n', '<leader>go', ':GithubOpen<CR>', { noremap = true, silent = true, desc = '[G]ithub [O]pen' })
vim.keymap.set('n', '<leader>gg', ':Git <CR>', { noremap = true, silent = true, desc = '[G] [G]it run' })
vim.keymap.set('n', ';', ':', { noremap = true })

vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })

vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true, desc = 'Move up' })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true, desc = 'Move down' })

-- moving line
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { noremap = true, silent = true, desc = 'Move line down' })
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv", { noremap = true, silent = true, desc = 'Move line up' })

-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
vim.keymap.set('n', '<leader>oe', vim.diagnostic.open_float, { desc = '[O]pen floating diagnostic message / [E]rrors' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })

-- navigate within insert mode
vim.keymap.set('i', '<C-j>', '<Down>', { desc = 'Move down' })
vim.keymap.set('i', '<C-k>', '<Up>', { desc = 'Move up' })
vim.keymap.set('i', '<C-l>', '<Right>', { desc = 'Move right' })
vim.keymap.set('i', '<C-h>', '<Left>', { desc = 'Move left' })
76 changes: 76 additions & 0 deletions nvim/lua/config/lspconfig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
local servers = {
-- clangd = {},
-- pyright = {},
-- rust_analyzer = {},
stylelint_lsp = { filetypes = { 'css', 'scss', 'sass' } },
eslint = { filetypes = { 'typescript', 'typescriptreact' } },
cssls = { filetypes = { 'css', 'scss', 'sass' } },
tailwindcss = { filetypes = { 'css', 'scss', 'sass' } },
tsserver = { filetypes = { 'typescript', 'typescriptreact' } },
html = { filetypes = { 'html' } },
gopls = {
filetypes = { 'go' },
gopls = {
gofumpt = true,
},
},

lua_ls = {
lua = {
workspace = { checkthirdparty = false },
telemetry = { enable = false },
},
},
}

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)

local mason_lspconfig = require 'mason-lspconfig'
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers),
}

local on_attach = function(_, bufnr)
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end

vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end

nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')

nmap('gd', function() vim.lsp.buf.definition { on_list = require('config.typescript').definition_on_list } end,
'[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')

-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<leader>K', vim.lsp.buf.signature_help, 'Signature Documentation')

-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
end

mason_lspconfig.setup_handlers {
function(server_name)
require('lspconfig')[server_name].setup {
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes,
}
end,
}
Loading

0 comments on commit f7b0ad5

Please sign in to comment.