Skip to content

Commit db6461f

Browse files
committed
Merge branch 'main' into fix-colors
2 parents 702f080 + fa2c6be commit db6461f

21 files changed

+656
-390
lines changed

Diff for: .github/workflows/release.yml

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
-
2121
name: Set up Go
2222
uses: actions/setup-go@v5
23+
24+
-
25+
name: Golangci-lint
26+
uses: golangci/[email protected]
27+
2328
-
2429
name: Run GoReleaser
2530
uses: goreleaser/goreleaser-action@v6

Diff for: .golangci.yml

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
# golangci-lint configuration file made by @ccoVeille
3+
# Source: https://github.com/ccoVeille/golangci-lint-config-examples/
4+
# Author: @ccoVeille
5+
# License: MIT
6+
# Variant: 03-safe
7+
# Version: v1.0.0
8+
#
9+
linters:
10+
# some linters are enabled by default
11+
# https://golangci-lint.run/usage/linters/
12+
#
13+
# enable some extra linters
14+
enable:
15+
# Errcheck is a program for checking for unchecked errors in Go code.
16+
- errcheck
17+
18+
# Linter for Go source code that specializes in simplifying code.
19+
- gosimple
20+
21+
# Vet examines Go source code and reports suspicious constructs.
22+
- govet
23+
24+
# Detects when assignments to existing variables are not used.
25+
- ineffassign
26+
27+
# It's a set of rules from staticcheck. See https://staticcheck.io/
28+
- staticcheck
29+
30+
# Fast, configurable, extensible, flexible, and beautiful linter for Go.
31+
# Drop-in replacement of golint.
32+
- revive
33+
34+
# check imports order and makes it always deterministic.
35+
- gci
36+
37+
# make sure to use t.Helper() when needed
38+
- thelper
39+
40+
# mirror suggests rewrites to avoid unnecessary []byte/string conversion
41+
- mirror
42+
43+
# detect the possibility to use variables/constants from the Go standard library.
44+
- usestdlibvars
45+
46+
# Finds commonly misspelled English words.
47+
- misspell
48+
49+
# Checks for duplicate words in the source code.
50+
- dupword
51+
52+
linters-settings:
53+
gci: # define the section orders for imports
54+
sections:
55+
# Standard section: captures all standard packages.
56+
- standard
57+
# Default section: catchall that is not standard or custom
58+
- default
59+
# linters that related to local tool, so they should be separated
60+
- localmodule
61+
62+
revive:
63+
rules:
64+
# these are the default revive rules
65+
# you can remove the whole "rules" node if you want
66+
# BUT
67+
# ! /!\ they all need to be present when you want to add more rules than the default ones
68+
# otherwise, you won't have the default rules, but only the ones you define in the "rules" node
69+
70+
# Blank import should be only in a main or test package, or have a comment justifying it.
71+
- name: blank-imports
72+
73+
# context.Context() should be the first parameter of a function when provided as argument.
74+
- name: context-as-argument
75+
arguments:
76+
- allowTypesBefore: "*testing.T"
77+
78+
# Basic types should not be used as a key in `context.WithValue`
79+
- name: context-keys-type
80+
81+
# Importing with `.` makes the programs much harder to understand
82+
- name: dot-imports
83+
84+
# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring.
85+
- name: empty-block
86+
87+
# for better readability, variables of type `error` must be named with the prefix `err`.
88+
- name: error-naming
89+
90+
# for better readability, the errors should be last in the list of returned values by a function.
91+
- name: error-return
92+
93+
# for better readability, error messages should not be capitalized or end with punctuation or a newline.
94+
- name: error-strings
95+
96+
# report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible
97+
- name: errorf
98+
99+
# incrementing an integer variable by 1 is recommended to be done using the `++` operator
100+
- name: increment-decrement
101+
102+
# highlights redundant else-blocks that can be eliminated from the code
103+
- name: indent-error-flow
104+
105+
# This rule suggests a shorter way of writing ranges that do not use the second value.
106+
- name: range
107+
108+
# receiver names in a method should reflect the struct name (p for Person, for example)
109+
- name: receiver-naming
110+
111+
# redefining built in names (true, false, append, make) can lead to bugs very difficult to detect.
112+
- name: redefines-builtin-id
113+
114+
# redundant else-blocks that can be eliminated from the code.
115+
- name: superfluous-else
116+
117+
# prevent confusing name for variables when using `time` package
118+
- name: time-naming
119+
120+
# warns when an exported function or method returns a value of an un-exported type.
121+
- name: unexported-return
122+
123+
# spots and proposes to remove unreachable code. also helps to spot errors
124+
- name: unreachable-code
125+
126+
# Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug.
127+
- name: unused-parameter
128+
129+
# report when a variable declaration can be simplified
130+
- name: var-declaration
131+
132+
# warns when initialism, variable or package naming conventions are not followed.
133+
- name: var-naming
134+
135+
dupword:
136+
# Keywords used to ignore detection.
137+
# Default: []
138+
ignore:
139+
# - "blah" # this will accept "blah blah …" as a valid duplicate word
140+
141+
misspell:
142+
# Correct spellings using locale preferences for US or UK.
143+
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
144+
# Default ("") is to use a neutral variety of English.
145+
locale: US
146+
147+
# List of words to ignore
148+
# among the one defined in https://github.com/golangci/misspell/blob/master/words.go
149+
ignore-words:
150+
# - valor
151+
# - and
152+
153+
# Extra word corrections.
154+
extra-words:
155+
# - typo: "whattever"
156+
# correction: "whatever"

Diff for: README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@
5454
![Product Name Screen Shot][product-screenshot1]
5555
![Product Name Screen Shot][product-screenshot2]
5656

57-
This project is heavily inspired by [Lazygit](https://github.com/jesseduffield/lazygit), which i think is the best TUI client for Git.
57+
This project is heavily inspired by [Lazygit](https://github.com/jesseduffield/lazygit), which I think is the best TUI client for Git.
5858

59-
I wanted to have a tool like that, but for SQL. I didn't find one that fits my needs so i created one myself.
59+
I wanted to have a tool like that, but for SQL. I didn't find one that fits my needs, so I created one myself.
6060

6161
I live in the terminal, so if you are like me, this tool can become handy for you too.
6262

63-
This is my first Open Source project, also, this is my first Golang project. I am not a brilliant programmer. I am just a typical Javascript developer that wanted to learn a new language, i also wanted a TUI SQL Client, so, white and bottled.
63+
This is my first Open Source project, also, this is my first Go project. I am not a brilliant programmer. I am just a typical JavaScript developer that wanted to learn a new language, I also wanted a TUI SQL Client, so white and bottled.
6464

65-
This project is in ALPHA stage, please feel free to critize my spaghetti code.
65+
This project is in ALPHA stage, please feel free to complain about my spaghetti code.
6666

67-
I use Lazysql daily in my ful time job as a fullstack javascript developer in it's current (buggy xD) state. So, the plan is to improve and fix my little boy as a side project in my free time.
67+
I use Lazysql daily in my full-time job as a full-stack javascript developer in its current (buggy xD) state. So, the plan is to improve and fix my little boy as a side-project in my free time.
6868

6969
### Built With
7070

@@ -74,7 +74,7 @@ I use Lazysql daily in my ful time job as a fullstack javascript developer in it
7474
## Features
7575

7676
- [x] Cross-platform (macOS, Windows, Linux)
77-
- [x] VIM Keybindings
77+
- [x] Vim Keybindings
7878
- [x] Can manage multiple connections (Backspace)
7979
- [x] Tabs
8080
- [x] SQL Editor (CTRL + e)
@@ -100,11 +100,11 @@ go install github.com/jorgerojas26/lazysql@latest
100100

101101
#### Binary Releases
102102

103-
For Windows, Mac OS or Linux, you can download a binary release [here](https://github.com/jorgerojas26/lazysql/releases)
103+
For Windows, macOS or Linux, you can download a binary release [here](https://github.com/jorgerojas26/lazysql/releases)
104104

105105
#### Third party (maintained by the community)
106106

107-
Archlinux users can install it from the AUR with:
107+
Arch Linux users can install it from the AUR with:
108108

109109
```bash
110110
paru -S lazysql
@@ -141,7 +141,7 @@ $ lazysql
141141
## Support
142142

143143
- [x] MySQL
144-
- [x] Postgres
144+
- [x] PostgreSQL
145145
- [x] SQLite
146146
- [ ] MSSQL
147147
- [ ] MongoDB
@@ -216,7 +216,7 @@ odbc+postgres://user:pass@localhost:port/dbname?option1=
216216

217217
## Roadmap
218218

219-
- [ ] Support for NOSQL databases
219+
- [ ] Support for NoSQL databases
220220
- [ ] Columns and indexes creation through TUI
221221
- [ ] Table tree input filter
222222
- [ ] Custom keybindings
@@ -231,7 +231,7 @@ See the [open issues](https://github.com/jorgerojas26/lazysql/issues) for a full
231231

232232
## Contributing
233233

234-
Contributions, issues and pull requests are welcome!
234+
Contributions, issues, and pull requests are welcome!
235235

236236
<p align="right">(<a href="#readme-top">back to top</a>)</p>
237237

@@ -247,7 +247,7 @@ Distributed under the MIT License. See `LICENSE.txt` for more information.
247247

248248
## Contact
249249

250-
Jorge Rojas - [Linkedin](https://www.linkedin.com/in/jorgerojas26/) - [email protected]
250+
Jorge Rojas - [LinkedIn](https://www.linkedin.com/in/jorgerojas26/) - [email protected]
251251

252252
<p align="right">(<a href="#readme-top">back to top</a>)</p>
253253

Diff for: app/Keymap.go

+44-36
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ package app
22

33
import (
44
"github.com/gdamore/tcell/v2"
5-
. "github.com/jorgerojas26/lazysql/commands"
6-
. "github.com/jorgerojas26/lazysql/keymap"
5+
6+
cmd "github.com/jorgerojas26/lazysql/commands"
7+
"github.com/jorgerojas26/lazysql/keymap"
8+
)
9+
10+
// local alias added for clarity purpose
11+
type (
12+
Bind = keymap.Bind
13+
Key = keymap.Key
14+
Map = keymap.Map
715
)
816

917
// KeymapSystem is the actual key mapping system.
@@ -31,54 +39,54 @@ func (c KeymapSystem) Group(name string) Map {
3139

3240
// Resolve translates a tcell.EventKey into a command based on the mappings in
3341
// the global group
34-
func (c KeymapSystem) Resolve(event *tcell.EventKey) Command {
42+
func (c KeymapSystem) Resolve(event *tcell.EventKey) cmd.Command {
3543
return c.Global.Resolve(event)
3644
}
3745

3846
// Define a global KeymapSystem object with default keybinds
39-
var Keymaps KeymapSystem = KeymapSystem{
47+
var Keymaps = KeymapSystem{
4048
Global: Map{
41-
Bind{Key: Key{Char: 'L'}, Cmd: MoveRight},
42-
Bind{Key: Key{Char: 'H'}, Cmd: MoveLeft},
43-
Bind{Key: Key{Code: tcell.KeyCtrlE}, Cmd: SwitchToEditorView},
44-
Bind{Key: Key{Code: tcell.KeyCtrlS}, Cmd: Save},
45-
Bind{Key: Key{Char: 'q'}, Cmd: Quit},
46-
Bind{Key: Key{Code: tcell.KeyBackspace2}, Cmd: SwitchToConnectionsView},
49+
Bind{Key: Key{Char: 'L'}, Cmd: cmd.MoveRight},
50+
Bind{Key: Key{Char: 'H'}, Cmd: cmd.MoveLeft},
51+
Bind{Key: Key{Code: tcell.KeyCtrlE}, Cmd: cmd.SwitchToEditorView},
52+
Bind{Key: Key{Code: tcell.KeyCtrlS}, Cmd: cmd.Save},
53+
Bind{Key: Key{Char: 'q'}, Cmd: cmd.Quit},
54+
Bind{Key: Key{Code: tcell.KeyBackspace2}, Cmd: cmd.SwitchToConnectionsView},
4755
},
4856
Groups: map[string]Map{
4957
"tree": {
50-
Bind{Key: Key{Char: 'g'}, Cmd: GotoTop},
51-
Bind{Key: Key{Char: 'G'}, Cmd: GotoBottom},
52-
Bind{Key: Key{Code: tcell.KeyEnter}, Cmd: Execute},
53-
Bind{Key: Key{Char: 'j'}, Cmd: MoveDown},
54-
Bind{Key: Key{Code: tcell.KeyDown}, Cmd: MoveDown},
55-
Bind{Key: Key{Char: 'k'}, Cmd: MoveUp},
56-
Bind{Key: Key{Code: tcell.KeyUp}, Cmd: MoveUp},
58+
Bind{Key: Key{Char: 'g'}, Cmd: cmd.GotoTop},
59+
Bind{Key: Key{Char: 'G'}, Cmd: cmd.GotoBottom},
60+
Bind{Key: Key{Code: tcell.KeyEnter}, Cmd: cmd.Execute},
61+
Bind{Key: Key{Char: 'j'}, Cmd: cmd.MoveDown},
62+
Bind{Key: Key{Code: tcell.KeyDown}, Cmd: cmd.MoveDown},
63+
Bind{Key: Key{Char: 'k'}, Cmd: cmd.MoveUp},
64+
Bind{Key: Key{Code: tcell.KeyUp}, Cmd: cmd.MoveUp},
5765
},
5866
"table": {
59-
Bind{Key: Key{Char: '/'}, Cmd: Search},
60-
Bind{Key: Key{Char: 'c'}, Cmd: Edit},
61-
Bind{Key: Key{Char: 'd'}, Cmd: Delete},
62-
Bind{Key: Key{Char: 'w'}, Cmd: GotoNext},
63-
Bind{Key: Key{Char: 'b'}, Cmd: GotoPrev},
64-
Bind{Key: Key{Char: '$'}, Cmd: GotoEnd},
65-
Bind{Key: Key{Char: '0'}, Cmd: GotoStart},
66-
Bind{Key: Key{Char: 'y'}, Cmd: Copy},
67-
Bind{Key: Key{Char: 'o'}, Cmd: AppendNewRow},
67+
Bind{Key: Key{Char: '/'}, Cmd: cmd.Search},
68+
Bind{Key: Key{Char: 'c'}, Cmd: cmd.Edit},
69+
Bind{Key: Key{Char: 'd'}, Cmd: cmd.Delete},
70+
Bind{Key: Key{Char: 'w'}, Cmd: cmd.GotoNext},
71+
Bind{Key: Key{Char: 'b'}, Cmd: cmd.GotoPrev},
72+
Bind{Key: Key{Char: '$'}, Cmd: cmd.GotoEnd},
73+
Bind{Key: Key{Char: '0'}, Cmd: cmd.GotoStart},
74+
Bind{Key: Key{Char: 'y'}, Cmd: cmd.Copy},
75+
Bind{Key: Key{Char: 'o'}, Cmd: cmd.AppendNewRow},
6876
// Tabs
69-
Bind{Key: Key{Char: '['}, Cmd: TabPrev},
70-
Bind{Key: Key{Char: ']'}, Cmd: TabNext},
71-
Bind{Key: Key{Char: '{'}, Cmd: TabFirst},
72-
Bind{Key: Key{Char: '}'}, Cmd: TabLast},
73-
Bind{Key: Key{Char: 'X'}, Cmd: TabClose},
77+
Bind{Key: Key{Char: '['}, Cmd: cmd.TabPrev},
78+
Bind{Key: Key{Char: ']'}, Cmd: cmd.TabNext},
79+
Bind{Key: Key{Char: '{'}, Cmd: cmd.TabFirst},
80+
Bind{Key: Key{Char: '}'}, Cmd: cmd.TabLast},
81+
Bind{Key: Key{Char: 'X'}, Cmd: cmd.TabClose},
7482
// Pages
75-
Bind{Key: Key{Char: '>'}, Cmd: PageNext},
76-
Bind{Key: Key{Char: '<'}, Cmd: PagePrev},
83+
Bind{Key: Key{Char: '>'}, Cmd: cmd.PageNext},
84+
Bind{Key: Key{Char: '<'}, Cmd: cmd.PagePrev},
7785
},
7886
"editor": {
79-
Bind{Key: Key{Code: tcell.KeyCtrlR}, Cmd: Execute},
80-
Bind{Key: Key{Code: tcell.KeyEscape}, Cmd: Quit},
81-
Bind{Key: Key{Code: tcell.KeyCtrlSpace}, Cmd: OpenInExternalEditor},
87+
Bind{Key: Key{Code: tcell.KeyCtrlR}, Cmd: cmd.Execute},
88+
Bind{Key: Key{Code: tcell.KeyEscape}, Cmd: cmd.Quit},
89+
Bind{Key: Key{Code: tcell.KeyCtrlSpace}, Cmd: cmd.OpenInExternalEditor},
8290
},
8391
},
8492
}

0 commit comments

Comments
 (0)